Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
17 | class BlankMiddleware implements MiddlewareInterface |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $isBroken; |
||
24 | |||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | private $isRunned = false; |
||
29 | |||
30 | /** |
||
31 | * @param bool $isBroken |
||
32 | */ |
||
33 | public function __construct(bool $isBroken = false) |
||
34 | { |
||
35 | $this->isBroken = $isBroken; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return bool |
||
40 | */ |
||
41 | public function isBroken() : bool |
||
42 | { |
||
43 | return $this->isBroken; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function isRunned() : bool |
||
50 | { |
||
51 | return $this->isRunned; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritDoc} |
||
56 | */ |
||
57 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface |
||
58 | { |
||
59 | $this->isRunned = true; |
||
60 | |||
61 | if ($this->isBroken) { |
||
62 | return (new ResponseFactory)->createResponse(); |
||
63 | } |
||
64 | |||
65 | return $handler->handle($request); |
||
66 | } |
||
68 |