canax/router

View on GitHub

Showing 28 of 66 total issues

Router has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Router implements ContainerInjectableInterface
{
    use ContainerInjectableTrait;


Severity: Minor
Found in src/Route/Router.php - About 2 hrs to fix

    File RouteHandler.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Anax\Route;
    
    use Anax\Commons\ContainerInjectableInterface;
    Severity: Minor
    Found in src/Route/RouteHandler.php - About 2 hrs to fix

      Method handleAsControllerAction has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function handleAsControllerAction(array $callable)
          {
              $class = $callable[0];
              $action = $callable[1];
              $args = $callable[2];
      Severity: Major
      Found in src/Route/RouteHandler.php - About 2 hrs to fix

        Function handleAsControllerAction has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function handleAsControllerAction(array $callable)
            {
                $class = $callable[0];
                $action = $callable[1];
                $args = $callable[2];
        Severity: Minor
        Found in src/Route/RouteHandler.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 handleAsInvocableClass has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function handleAsInvocableClass(string $class)
            {
                $obj = new $class();
                // $class = $callable[0];
                $action = "__invoke";
        Severity: Minor
        Found in src/Route/RouteHandler.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 handleAsInvocableClass has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function handleAsInvocableClass(string $class)
            {
                $obj = new $class();
                // $class = $callable[0];
                $action = "__invoke";
        Severity: Minor
        Found in src/Route/RouteHandler.php - About 1 hr to fix

          Method match has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function match(
                  ?string $mount,
                  ?string $relativePath,
                  ?string $absolutePath,
                  ?string $query,
          Severity: Minor
          Found in src/Route/RouteMatcher.php - About 1 hr to fix

            Function match has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function match(
                    ?string $mount,
                    ?string $relativePath,
                    ?string $absolutePath,
                    ?string $query,
            Severity: Minor
            Found in src/Route/RouteMatcher.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

            Function handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function handle(
                    ?string $method,
                    ?string $path,
                    $action,
                    array $arguments = [],
            Severity: Minor
            Found in src/Route/RouteHandler.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

            Function handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function handle($path, $method = null)
                {
                    try {
                        $match = false;
                        foreach ($this->routes as $route) {
            Severity: Minor
            Found in src/Route/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 handle has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function handle(
                    ?string $method,
                    ?string $path,
                    $action,
                    array $arguments = [],
            Severity: Minor
            Found in src/Route/RouteHandler.php - About 1 hr to fix

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

                  protected function isControllerAction(
                      ?string $method,
                      ?string $path,
                      string $class
                  ) {
              Severity: Minor
              Found in src/Route/RouteHandler.php - About 1 hr to fix

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

                    protected function isControllerAction(
                        ?string $method,
                        ?string $path,
                        string $class
                    ) {
                Severity: Minor
                Found in src/Route/RouteHandler.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

                Consider simplifying this complex logical expression.
                Open

                        if ($di
                            && is_array($action)
                            && isset($action[0])
                            && isset($action[1])
                            && is_string($action[0])
                Severity: Major
                Found in src/Route/RouteHandler.php - About 1 hr to fix

                  Method match has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          ?string $mount,
                          ?string $relativePath,
                          ?string $absolutePath,
                          ?string $query,
                          ?array $methodSupported,
                  Severity: Minor
                  Found in src/Route/RouteMatcher.php - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (is_array($action)
                                && isset($action[0])
                                && isset($action[1])
                                && is_string($action[0])
                                && is_string($action[1])
                    Severity: Major
                    Found in src/Route/RouteHandler.php - About 40 mins to fix

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

                              ?string $method,
                              ?string $path,
                              $action,
                              array $arguments = [],
                              ContainerInterface $di = null
                      Severity: Minor
                      Found in src/Route/RouteHandler.php - About 35 mins to fix

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

                                $method,
                                $mount = null,
                                $path = null,
                                $handler = null,
                                string $info = null
                        Severity: Minor
                        Found in src/Route/Router.php - About 35 mins to fix

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

                                  $method = null,
                                  $mount = null,
                                  $path = null,
                                  $handler = null,
                                  string $info = null
                          Severity: Minor
                          Found in src/Route/Route.php - About 35 mins to fix

                            Function getHandlerType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function getHandlerType(
                                    $action,
                                    ContainerInterface $di = null
                                ) {
                                    if (is_null($action)) {
                            Severity: Minor
                            Found in src/Route/RouteHandler.php - About 35 mins 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

                            Severity
                            Category
                            Status
                            Source
                            Language