Code Duplication    Length = 10-10 lines in 2 locations

src/Routing/Dispatcher/ClosureDispatcher.php 1 location

@@ 44-53 (lines=10) @@
41
42
        $params = empty($this->router->route->getParameters()) ? $classInstance : array_merge($this->router->route->getParameters(), $classInstance);
43
        $content = call_user_func_array($this->router->route->getTarget('closure'), $params);
44
        if ($content instanceof ResponseInterface) {
45
            $this->router->response = $content;
46
        } else {
47
            if (is_array($content)) {
48
                $this->router->route->addTarget('data', $content);
49
                $content = json_encode($content);
50
            }
51
            $this->router->callMiddleware('between');
52
            $this->router->response->setContent($content);
53
        }
54
    }
55
56
}

src/Routing/Dispatcher/ControllerDispatcher.php 1 location

@@ 70-79 (lines=10) @@
67
        if ($count == count($this->router->route->getParameters()) || ($this->router->route->getParameters() == '' && $count == 0)) {
68
            $dependencies = array_merge($dependencies, ($this->router->route->getParameters() == '') ? [] : $this->router->route->getParameters());
69
            $content = $reflectionMethod->invokeArgs($this->getController($classInstance), $dependencies);
70
            if ($content instanceof ResponseInterface) {
71
                $this->router->response = $content;
72
            } else {
73
                if (is_array($content)) {
74
                    $this->router->route->addTarget('data', $content);
75
                    $content = json_encode($content);
76
                }
77
                $this->router->callMiddleware('between');
78
                $this->router->response->setContent($content);
79
            }
80
        } else {
81
            $this->router->response->setStatusCode(404);
82
        }