Total Complexity | 5 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
16 | class BlankRequestHandler implements RequestHandlerInterface |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | private $isRunned = false; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $attributes = []; |
||
28 | |||
29 | /** |
||
30 | * @return bool |
||
31 | */ |
||
32 | public function isRunned() : bool |
||
33 | { |
||
34 | return $this->isRunned; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return array |
||
39 | */ |
||
40 | public function getAttributes() : array |
||
41 | { |
||
42 | return $this->attributes; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param mixed $key |
||
47 | * |
||
48 | * @return mixed |
||
49 | */ |
||
50 | public function getAttribute($key) |
||
51 | { |
||
52 | return $this->attributes[$key] ?? null; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | public function handle(ServerRequestInterface $request) : ResponseInterface |
||
59 | { |
||
60 | $this->isRunned = true; |
||
61 | $this->attributes = $request->getAttributes(); |
||
62 | |||
63 | return (new ResponseFactory)->createResponse(); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param ServerRequestInterface $request |
||
68 | * |
||
69 | * @return ResponseInterface |
||
70 | * |
||
71 | * @link https://www.php.net/manual/ru/language.oop5.magic.php#object.invoke |
||
72 | */ |
||
73 | public function __invoke(ServerRequestInterface $request) : ResponseInterface |
||
74 | { |
||
75 | return $this->handle($request); |
||
76 | } |
||
78 |