steeffeen/FancyManiaLinks

View on GitHub
FML/Script/Features/Toggle.php

Summary

Maintainability
A
35 mins
Test Coverage
C
73%

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

        Control $togglingControl = null,
        Control $toggledControl = null,
        $labelName = ScriptLabel::MOUSECLICK,
        $onlyShow = false,
        $onlyHide = false
Severity: Minor
Found in FML/Script/Features/Toggle.php - About 35 mins to fix

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

            $onlyShow = false,
    Severity: Minor
    Found in FML/Script/Features/Toggle.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

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

            $onlyHide = false
    Severity: Minor
    Found in FML/Script/Features/Toggle.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

    Avoid using static access to class '\FML\Script\Builder' in method 'getScriptText'.
    Open

            $togglingControlId = Builder::escapeText($this->togglingControl->getId());
    Severity: Minor
    Found in FML/Script/Features/Toggle.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\FML\Script\Builder' in method 'getScriptText'.
    Open

            $toggledControlId  = Builder::escapeText($this->toggledControl->getId());
    Severity: Minor
    Found in FML/Script/Features/Toggle.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    The closing brace for the class must go on the next line after the body
    Open

    }

    The 'getOnlyShow()' method which returns a boolean should be named 'is...()' or 'has...()'
    Open

        public function getOnlyShow()
        {
            return $this->onlyShow;
        }
    Severity: Minor
    Found in FML/Script/Features/Toggle.php by phpmd

    BooleanGetMethodName

    Since: 0.2

    Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

    Example

    class Foo {
        /**
         * @return boolean
         */
        public function getFoo() {} // bad
        /**
         * @return bool
         */
        public function isFoo(); // ok
        /**
         * @return boolean
         */
        public function getFoo($bar); // ok, unless checkParameterizedMethods=true
    }

    Source https://phpmd.org/rules/naming.html#booleangetmethodname

    The 'getOnlyHide()' method which returns a boolean should be named 'is...()' or 'has...()'
    Open

        public function getOnlyHide()
        {
            return $this->onlyHide;
        }
    Severity: Minor
    Found in FML/Script/Features/Toggle.php by phpmd

    BooleanGetMethodName

    Since: 0.2

    Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

    Example

    class Foo {
        /**
         * @return boolean
         */
        public function getFoo() {} // bad
        /**
         * @return bool
         */
        public function isFoo(); // ok
        /**
         * @return boolean
         */
        public function getFoo($bar); // ok, unless checkParameterizedMethods=true
    }

    Source https://phpmd.org/rules/naming.html#booleangetmethodname

    Usage of ELSE IF is discouraged; use ELSEIF instead
    Open

            } else if ($this->onlyHide) {

    There are no issues that match your filters.

    Category
    Status