iranianpep/code-jetter

View on GitHub
core/Router.php

Summary

Maintainability
F
3 days
Test Coverage

Function authorizeRoute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function authorizeRoute($accessRole, $rootNamespace, $component, $controller, $redirect = true)
    {
        $roles = Registry::getConfigClass()->get('roles');
        $redirections = Registry::getConfigClass()->get('redirections');

Severity: Minor
Found in core/Router.php - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

The class Router has an overall complexity of 73 which is very high. The configured complexity threshold is 50.
Open

class Router
{
    private static $defaultComponent;
    private static $defaultController;
    private static $defaultAction;
Severity: Minor
Found in core/Router.php by phpmd

Function getRouteInfo has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRouteInfo($urlPath, $requestMethod)
    {
        if (empty($requestMethod)) {
            return false;
        }
Severity: Minor
Found in core/Router.php - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File Router.php has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CodeJetter\core;

use CodeJetter\components\page\models\MetaTag;
Severity: Minor
Found in core/Router.php - About 2 hrs to fix

    Function getAccessRole has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getAccessRole($urlPath, $roles = [])
        {
            if (empty($roles)) {
                $roles = Registry::getConfigClass()->get('roles');
            }
    Severity: Minor
    Found in core/Router.php - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function regexMatch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function regexMatch($pattern, $path)
        {
            if (empty($pattern) || empty($path)) {
                return false;
            }
    Severity: Minor
    Found in core/Router.php - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method getRouteInfo has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getRouteInfo($urlPath, $requestMethod)
        {
            if (empty($requestMethod)) {
                return false;
            }
    Severity: Major
    Found in core/Router.php - About 2 hrs to fix

      Method route has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function route()
          {
              // get request method and URI
              $request = new Request();
              $requestMethod = $request->getRequestMethod();
      Severity: Minor
      Found in core/Router.php - About 2 hrs to fix

        Method authorizeRoute has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function authorizeRoute($accessRole, $rootNamespace, $component, $controller, $redirect = true)
            {
                $roles = Registry::getConfigClass()->get('roles');
                $redirections = Registry::getConfigClass()->get('redirections');
        
        
        Severity: Minor
        Found in core/Router.php - About 2 hrs to fix

          Method regexMatch has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function regexMatch($pattern, $path)
              {
                  if (empty($pattern) || empty($path)) {
                      return false;
                  }
          Severity: Minor
          Found in core/Router.php - About 1 hr to fix

            Method getAccessRole has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getAccessRole($urlPath, $roles = [])
                {
                    if (empty($roles)) {
                        $roles = Registry::getConfigClass()->get('roles');
                    }
            Severity: Minor
            Found in core/Router.php - About 1 hr to fix

              Function route has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function route()
                  {
                      // get request method and URI
                      $request = new Request();
                      $requestMethod = $request->getRequestMethod();
              Severity: Minor
              Found in core/Router.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  public function authorizeRoute($accessRole, $rootNamespace, $component, $controller, $redirect = true)
              Severity: Minor
              Found in core/Router.php - About 35 mins to fix

                The method route() has an NPath complexity of 576. The configured NPath complexity threshold is 200.
                Open

                    public function route()
                    {
                        // get request method and URI
                        $request = new Request();
                        $requestMethod = $request->getRequestMethod();
                Severity: Minor
                Found in core/Router.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                The method getRouteInfo() has an NPath complexity of 12288. The configured NPath complexity threshold is 200.
                Open

                    public function getRouteInfo($urlPath, $requestMethod)
                    {
                        if (empty($requestMethod)) {
                            return false;
                        }
                Severity: Minor
                Found in core/Router.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                The method regexMatch() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                Open

                    public function regexMatch($pattern, $path)
                    {
                        if (empty($pattern) || empty($path)) {
                            return false;
                        }
                Severity: Minor
                Found in core/Router.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The method authorizeRoute() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                Open

                    public function authorizeRoute($accessRole, $rootNamespace, $component, $controller, $redirect = true)
                    {
                        $roles = Registry::getConfigClass()->get('roles');
                        $redirections = Registry::getConfigClass()->get('redirections');
                
                
                Severity: Minor
                Found in core/Router.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The method getAccessRole() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                Open

                    private function getAccessRole($urlPath, $roles = [])
                    {
                        if (empty($roles)) {
                            $roles = Registry::getConfigClass()->get('roles');
                        }
                Severity: Minor
                Found in core/Router.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The method getRouteInfo() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                Open

                    public function getRouteInfo($urlPath, $requestMethod)
                    {
                        if (empty($requestMethod)) {
                            return false;
                        }
                Severity: Minor
                Found in core/Router.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The method route() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                Open

                    public function route()
                    {
                        // get request method and URI
                        $request = new Request();
                        $requestMethod = $request->getRequestMethod();
                Severity: Minor
                Found in core/Router.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                The class Router has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
                Open

                class Router
                {
                    private static $defaultComponent;
                    private static $defaultController;
                    private static $defaultAction;
                Severity: Minor
                Found in core/Router.php by phpmd

                CouplingBetweenObjects

                Since: 1.1.0

                A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                Example

                class Foo {
                    /**
                     * @var \foo\bar\X
                     */
                    private $x = null;
                
                    /**
                     * @var \foo\bar\Y
                     */
                    private $y = null;
                
                    /**
                     * @var \foo\bar\Z
                     */
                    private $z = null;
                
                    public function setFoo(\Foo $foo) {}
                    public function setBar(\Bar $bar) {}
                    public function setBaz(\Baz $baz) {}
                
                    /**
                     * @return \SplObjectStorage
                     * @throws \OutOfRangeException
                     * @throws \InvalidArgumentException
                     * @throws \ErrorException
                     */
                    public function process(\Iterator $it) {}
                
                    // ...
                }

                Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                Missing class import via use statement (line '269', column '23').
                Open

                            throw new \Exception('Controller and action cannot be empty');
                Severity: Minor
                Found in core/Router.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 authorizeRoute has a boolean flag argument $redirect, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function authorizeRoute($accessRole, $rootNamespace, $component, $controller, $redirect = true)
                Severity: Minor
                Found in core/Router.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 '417', column '23').
                Open

                            throw new \Exception('Invalid User');
                Severity: Minor
                Found in core/Router.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 '353', column '31').
                Open

                                    throw new \Exception("baseURL for roles must be unique. '{$role['baseURL']}' is not unique.");
                Severity: Minor
                Found in core/Router.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 authorizeRoute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                } else {
                                    if (isset($redirections[$userModel]) && isset($redirections[$userModel]['default'])) {
                                        header('Location: '.$redirections[$userModel]['default']);
                                    }
                                    exit;
                Severity: Minor
                Found in core/Router.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

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

                        } else {
                            // look for regex
                            if (!empty($routes['regex'][$requestMethod])) {
                                foreach ($routes['regex'][$requestMethod] as $routePattern => $routeInfo) {
                                    // find the match and return parameters if there is any
                Severity: Minor
                Found in core/Router.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 using static access to class 'CodeJetter\core\App' in method 'route'.
                Open

                                $app = App::getInstance();
                Severity: Minor
                Found in core/Router.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 method authorizeRoute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $model = "{$rootNamespace}\\components\\{$component}\\models\\{$controller}";
                            $userModel = $controller;
                        }
                Severity: Minor
                Found in core/Router.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

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

                        } else {
                            return false;
                        }
                Severity: Minor
                Found in core/Router.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

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

                                } else {
                                    // default
                                    $regexTypedPattern = static::$regexTypedPatterns['string'];
                                }
                Severity: Minor
                Found in core/Router.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

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

                                } else {
                                    $optional = '';
                                }
                Severity: Minor
                Found in core/Router.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

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

                        } else {
                            // checkAntiCSRFToken is NOT set, use default value based on request method
                            switch ($requestMethod) {
                                case 'POST':
                                    $routeInfoObject->setCheckAntiCSRFToken(true);
                Severity: Minor
                Found in core/Router.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

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

                            } else {
                                return $result;
                            }
                Severity: Minor
                Found in core/Router.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

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

                        } else {
                            if ($userAuthentication->isLoggedIn($user, true) === true) {
                                // e.g. User is already logged in, and tries to login in login page
                                if ((new Request())->isAJAX()) {
                                    $output = new Output();
                Severity: Minor
                Found in core/Router.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

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

                            } else {
                                $regexPattern .= '/'.$patternPiece;
                            }
                Severity: Minor
                Found in core/Router.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

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

                            } else {
                                return $result;
                            }
                Severity: Minor
                Found in core/Router.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

                The method route() contains an exit expression.
                Open

                            exit();
                Severity: Minor
                Found in core/Router.php by phpmd

                ExitExpression

                Since: 0.2

                An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                Example

                class Foo {
                    public function bar($param)  {
                        if ($param === 42) {
                            exit(23);
                        }
                    }
                }

                Source https://phpmd.org/rules/design.html#exitexpression

                The method authorizeRoute() contains an exit expression.
                Open

                                    exit;
                Severity: Minor
                Found in core/Router.php by phpmd

                ExitExpression

                Since: 0.2

                An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                Example

                class Foo {
                    public function bar($param)  {
                        if ($param === 42) {
                            exit(23);
                        }
                    }
                }

                Source https://phpmd.org/rules/design.html#exitexpression

                The method authorizeRoute() contains an exit expression.
                Open

                                exit;
                Severity: Minor
                Found in core/Router.php by phpmd

                ExitExpression

                Since: 0.2

                An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                Example

                class Foo {
                    public function bar($param)  {
                        if ($param === 42) {
                            exit(23);
                        }
                    }
                }

                Source https://phpmd.org/rules/design.html#exitexpression

                The method authorizeRoute() contains an exit expression.
                Open

                                exit;
                Severity: Minor
                Found in core/Router.php by phpmd

                ExitExpression

                Since: 0.2

                An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                Example

                class Foo {
                    public function bar($param)  {
                        if ($param === 42) {
                            exit(23);
                        }
                    }
                }

                Source https://phpmd.org/rules/design.html#exitexpression

                Avoid variables with short names like $i. Configured minimum length is 3.
                Open

                        $i = 0;
                Severity: Minor
                Found in core/Router.php by phpmd

                ShortVariable

                Since: 0.2

                Detects when a field, local, or parameter has a very short name.

                Example

                class Something {
                    private $q = 15; // VIOLATION - Field
                    public static function main( array $as ) { // VIOLATION - Formal
                        $r = 20 + $this->q; // VIOLATION - Local
                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                            $r += $this->q;
                        }
                    }
                }

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

                The variable $HTTPInputs is not named in camelCase.
                Open

                    public function route()
                    {
                        // get request method and URI
                        $request = new Request();
                        $requestMethod = $request->getRequestMethod();
                Severity: Minor
                Found in core/Router.php by phpmd

                CamelCaseVariableName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name variables.

                Example

                class ClassName {
                    public function doSomething() {
                        $data_module = new DataModule();
                    }
                }

                Source

                The variable $HTTPInputs is not named in camelCase.
                Open

                    public function route()
                    {
                        // get request method and URI
                        $request = new Request();
                        $requestMethod = $request->getRequestMethod();
                Severity: Minor
                Found in core/Router.php by phpmd

                CamelCaseVariableName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name variables.

                Example

                class ClassName {
                    public function doSomething() {
                        $data_module = new DataModule();
                    }
                }

                Source

                There are no issues that match your filters.

                Category
                Status