brokencube/circuit

View on GitHub
src/Router.php

Summary

Maintainability
A
1 hr
Test Coverage

Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(Request $request) : Response
    {
        // Try and run the next middleware
        $next = next($this->prerouteMiddleware);
        if ($next instanceof Middleware) {
Severity: Minor
Found in src/Router.php - About 1 hr to fix

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

    class Router implements Delegate, LoggerAwareInterface
    {
        use LoggerAwareTrait;
        
        const CACHE_KEY = 'routes_v3';
    Severity: Minor
    Found in src/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 '209', column '25').
    Open

                return (new \Circuit\ExceptionHandler\DefaultHandler)->handle($e, $request);
    Severity: Minor
    Found in src/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 '259', column '23').
    Open

                throw new \UnexpectedValueException("No middleware registered under name '{$name}'");
    Severity: Minor
    Found in src/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

    Possibly zero references to use statement for classlike/namespace ParameterDereferencer (\Circuit\Interfaces\ParameterDereferencer)
    Open

    use Circuit\Interfaces\ParameterDereferencer;
    Severity: Minor
    Found in src/Router.php by phan

    Doc-block of $e in handleException contains phpdoc param type \Circuit\Throwable which is incompatible with the param type \Throwable declared in the signature
    Open

         * @param Throwable $e The Exception / Error thrown.
    Severity: Minor
    Found in src/Router.php by phan

    Argument 2 (args) is class-string but \Circuit\Router::log() takes mixed[] defined at /code/src/Router.php:309
    Open

                $this->log("Router: Leaving Middleware: %s", get_class($next));
    Severity: Minor
    Found in src/Router.php by phan

    Argument 2 (args) is string but \Circuit\Router::log() takes mixed[] defined at /code/src/Router.php:309
    Open

                $this->log("Router: Leaving Middleware: %s", $next);
    Severity: Minor
    Found in src/Router.php by phan

    Argument 2 (args) is float|int but \Circuit\Router::log() takes mixed[] defined at /code/src/Router.php:309
    Open

            $this->log("Router: ->run() called. Starting clock at REQUEST_TIME+%.2fms", microtime(true) - $starttime);
    Severity: Minor
    Found in src/Router.php by phan

    Saw an @param annotation for code, but it was not found in the param list of function setDefaultExceptionHandler(\Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
    Open

         * @param string $code HTTP code handler is responsible for
    Severity: Info
    Found in src/Router.php by phan

    Doc-block of $container in setServiceContainer contains phpdoc param type \Circuit\Psr\Container\ContainerInterface which is incompatible with the param type \Psr\Container\ContainerInterface declared in the signature
    Open

         * @param Psr\Container\ContainerInterface $container Service container passed to controller constructor
    Severity: Minor
    Found in src/Router.php by phan

    Argument 2 (args) is string but \Circuit\Router::log() takes mixed[] defined at /code/src/Router.php:309
    Open

                $this->log("Router: Calling Middleware: %s", $next);
    Severity: Minor
    Found in src/Router.php by phan

    mixed[] $args is not variadic in comment, but variadic in param (...$args)
    Open

         * @param mixed[] $args Data to pass to sprintf
    Severity: Info
    Found in src/Router.php by phan

    Argument 2 (args) is class-string but \Circuit\Router::log() takes mixed[] defined at /code/src/Router.php:309
    Open

                $this->log("Router: Calling Middleware: %s", get_class($next));
    Severity: Minor
    Found in src/Router.php by phan

    Saw an @param annotation for hander, but it was not found in the param list of function setExceptionHandler(string $code, \Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
    Open

         * @param ExceptionHandler $hander Handler
    Severity: Info
    Found in src/Router.php by phan

    Saw an @param annotation for hander, but it was not found in the param list of function setDefaultExceptionHandler(\Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
    Open

         * @param ExceptionHandler $hander Handler
    Severity: Info
    Found in src/Router.php by phan

    Avoid excessively long variable names like $defaultExceptionHandler. Keep variable name length under 20.
    Open

        public $defaultExceptionHandler = null;
    Severity: Minor
    Found in src/Router.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

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

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

        protected function handleException(\Throwable $e, Request $request) : Response
    Severity: Minor
    Found in src/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

    There are no issues that match your filters.

    Category
    Status