Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 73.32% |
Changes | 0 |
1 | <?php |
||
7 | final class Request |
||
8 | { |
||
9 | public const METHOD_CONNECT = 'CONNECT'; |
||
10 | public const METHOD_DELETE = 'DELETE'; |
||
11 | public const METHOD_GET = 'GET'; |
||
12 | public const METHOD_HEAD = 'HEAD'; |
||
13 | public const METHOD_OPTIONS = 'OPTIONS'; |
||
14 | public const METHOD_PATCH = 'PATCH'; |
||
15 | public const METHOD_POST = 'POST'; |
||
16 | public const METHOD_PUT = 'PUT'; |
||
17 | public const METHOD_TRACE = 'TRACE'; |
||
18 | |||
19 | 42 | public function __construct( |
|
20 | private array $query, |
||
21 | private array $request, |
||
22 | private array $server, |
||
23 | ) { |
||
24 | 42 | } |
|
25 | |||
26 | 42 | public static function fromGlobals(): self |
|
27 | { |
||
28 | 42 | return new self($_GET, $_POST, $_SERVER); |
|
29 | } |
||
30 | |||
31 | 42 | public function isMethod(string $method): bool |
|
32 | { |
||
33 | /** @psalm-suppress PossiblyUndefinedArrayOffset */ |
||
34 | 42 | return (string)$this->server['REQUEST_METHOD'] === $method; |
|
35 | } |
||
36 | |||
37 | 41 | public function path(): string |
|
43 | 41 | ); |
|
44 | } |
||
45 | |||
46 | public function get(string $key): mixed |
||
53 |