mambax7/publisher

View on GitHub
class/GroupPermHandler.php

Summary

Maintainability
A
35 mins
Test Coverage

Method checkRight has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1, $trueifadmin = true) //checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1)
Severity: Minor
Found in class/GroupPermHandler.php - About 35 mins to fix

    Missing class import via use statement (line '46', column '44').
    Open

            $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $gpermModId));
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '55', column '37').
    Open

                    $criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR');
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    The method checkRight has a boolean flag argument $trueifadmin, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1, $trueifadmin = true) //checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1)
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Missing class import via use statement (line '47', column '28').
    Open

            $criteria->add(new \Criteria('gperm_name', $gpermName));
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '53', column '30').
    Open

                $criteria2 = new \CriteriaCompo();
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '46', column '25').
    Open

            $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $gpermModId));
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '50', column '32').
    Open

                $criteria->add(new \Criteria('gperm_itemid', $gpermItemId));
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '59', column '32').
    Open

                $criteria->add(new \Criteria('gperm_groupid', $gpermGroupId));
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    The method checkRight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $criteria->add(new \Criteria('gperm_groupid', $gpermGroupId));
            }
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid unused parameters such as '$trueifadmin'.
    Open

        public function checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1, $trueifadmin = true) //checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1)
    Severity: Minor
    Found in class/GroupPermHandler.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 30 and the first side effect is on line 23.
    Open

    <?php declare(strict_types=1);
    Severity: Minor
    Found in class/GroupPermHandler.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status