| Total Complexity | 8 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Runner implements RequestHandlerInterface |
||
| 11 | { |
||
| 12 | /** @var MiddlewareManager */ |
||
| 13 | protected $manager; |
||
| 14 | /** @var int */ |
||
| 15 | protected $index = 0; |
||
| 16 | |||
| 17 | /** @var PathResolver|null */ |
||
| 18 | protected $pathResolver; |
||
| 19 | |||
| 20 | public function __construct(MiddlewareManager $manager) |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @inheritdoc |
||
| 27 | */ |
||
| 28 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 29 | { |
||
| 30 | [$next, $path] = $this->manager->get($this->index); |
||
| 31 | |||
| 32 | if (null === $next) { |
||
| 33 | throw new \OutOfRangeException('Handler not found'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->rewindBy(1); |
||
| 37 | $response = $this->callNext($path, $request, $next); |
||
| 38 | $this->rewindBy(-1); |
||
| 39 | |||
| 40 | return $response; |
||
| 41 | } |
||
| 42 | |||
| 43 | protected function callNext(?string $path, ServerRequestInterface $request, MiddlewareInterface $next) |
||
| 44 | { |
||
| 45 | if (null === $path) { |
||
| 46 | return $next->process($request, $this); |
||
| 47 | } |
||
| 48 | |||
| 49 | return $this->pathResolver->isMatch($path, $request) |
||
|
|
|||
| 50 | ? $next->process($request, $this) |
||
| 51 | : $this->handle($request); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function setPathResolver(?PathResolver $resolver): void |
||
| 55 | { |
||
| 56 | $this->pathResolver = $resolver; |
||
| 57 | } |
||
| 58 | |||
| 59 | protected function rewindBy(int $val = 1): void |
||
| 62 | } |
||
| 63 | } |
||
| 64 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.