1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Flight Routing. |
5
|
|
|
* |
6
|
|
|
* PHP version 8.0 and above required |
7
|
|
|
* |
8
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
9
|
|
|
* @copyright 2019 Divine Niiquaye Ibok (https://divinenii.com/) |
10
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause License |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please view the LICENSE |
13
|
|
|
* file that was distributed with this source code. |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Flight\Routing\Tests\Fixtures; |
17
|
|
|
|
18
|
|
|
use Nyholm\Psr7\Factory\Psr17Factory; |
19
|
|
|
use Psr\Http\Message\ResponseInterface; |
20
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
21
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* BlankRequestHandler. |
25
|
|
|
*/ |
26
|
|
|
class BlankRequestHandler implements RequestHandlerInterface |
27
|
|
|
{ |
28
|
|
|
private bool $isDone = false; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param array<string,mixed> $attributes |
32
|
|
|
*/ |
33
|
|
|
public function __construct(private array $attributes = []) |
34
|
|
|
{ |
35
|
|
|
$this->attributes = $attributes; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public static function __set_state(array $properties): static |
39
|
|
|
{ |
40
|
|
|
$new = new static(); |
41
|
|
|
|
42
|
|
|
foreach ($properties as $property => $value) { |
43
|
|
|
$new->{$property} = $value; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $new; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function isDone(): bool |
50
|
|
|
{ |
51
|
|
|
return $this->isDone; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array<string,mixed> |
56
|
|
|
*/ |
57
|
|
|
public function getAttributes(): array |
58
|
|
|
{ |
59
|
|
|
return $this->attributes; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getAttribute(string $key): mixed |
63
|
|
|
{ |
64
|
|
|
return $this->attributes[$key] ?? null; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
71
|
|
|
{ |
72
|
|
|
$this->attributes = $request->getAttributes(); |
73
|
|
|
|
74
|
|
|
try { |
75
|
|
|
return (new Psr17Factory())->createResponse(); |
76
|
|
|
} finally { |
77
|
|
|
$this->isDone = true; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|