brokencube/circuit

View on GitHub
src/HandlerContainer.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    public function process(Request $request) : Response
    {
        $router = $request->attributes->get('router');
        
        $next = next($this->middlewareStack);
Severity: Minor
Found in src/HandlerContainer.php - About 1 hr to fix

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

        public function process(Request $request) : Response
        {
            $router = $request->attributes->get('router');
            
            $next = next($this->middlewareStack);
    Severity: Minor
    Found in src/HandlerContainer.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

    Avoid too many return statements within this method.
    Open

                return new Response(
                    $return,
                    Response::HTTP_OK,
                    array('content-type' => 'text/html')
                );
    Severity: Major
    Found in src/HandlerContainer.php - About 30 mins to fix

      Doc-block of $stack in __construct contains phpdoc param type \Circuit\Interfaces\Middleware which is incompatible with the param type array declared in the signature
      Open

           * @param Middleware|string[] $stack    A list of middleware (Middleware Objects or named Middleware) to be called
      Severity: Minor
      Found in src/HandlerContainer.php by phan

      Returning type \Symfony\Component\HttpFoundation\JsonResponse but process() is declared to return \Symfony\Component\HttpFoundation\Response
      Open

                      return new JsonResponse(
      Severity: Minor
      Found in src/HandlerContainer.php by phan

      Argument 5 (container) is \Circuit\Psr\Container\ContainerInterface but \Circuit\ControllerParams::__construct() takes \Psr\Container\ContainerInterface defined at /code/src/ControllerParams.php:36
      Open

              $params = new ControllerParams($uri, $this->controllerClass, $this->controllerMethod, $args, $router->getServiceContainer());
      Severity: Minor
      Found in src/HandlerContainer.php by phan

      Doc-block of $stack in addMiddleware contains phpdoc param type \Circuit\Interfaces\Middleware which is incompatible with the param type array declared in the signature
      Open

           * @param Middleware|string[] $stack Middleware to add to this route.
      Severity: Minor
      Found in src/HandlerContainer.php by phan

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

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

      Line exceeds 120 characters; contains 128 characters
      Open

                  $return = (new $params->className($params->container))->{$params->method}($request, ...array_values($params->args));
      Severity: Minor
      Found in src/HandlerContainer.php by phpcodesniffer

      Line exceeds 120 characters; contains 133 characters
      Open

              $params = new ControllerParams($uri, $this->controllerClass, $this->controllerMethod, $args, $router->getServiceContainer());
      Severity: Minor
      Found in src/HandlerContainer.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status