Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
20 | 4 | public function handle(ServerRequestInterface $request): ResponseInterface |
|
21 | { |
||
22 | 4 | if ($this->stack->count() === 0) { |
|
23 | 1 | throw new \RuntimeException('No more middleware\'s to call on.'); |
|
24 | } |
||
25 | 4 | if ($this->called) { |
|
26 | 1 | throw new \RuntimeException('Already processed, cannot be ran twice.'); |
|
27 | } |
||
28 | |||
29 | /** @var MiddlewareInterface $next */ |
||
30 | 4 | $next = $this->stack->pop(); |
|
31 | 4 | $this->called = true; |
|
32 | |||
33 | 4 | return $next->process($request, new self($this->stack)); |
|
34 | } |
||
36 |