Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 53.85% |
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 | public function __construct( |
||
20 | private array $globalGet, |
||
21 | ) { |
||
22 | } |
||
23 | |||
24 | public static function fromGlobals(): self |
||
25 | { |
||
26 | return new self($_GET); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return self::METHOD_* |
||
31 | */ |
||
32 | 40 | public static function method(): string |
|
33 | { |
||
34 | /** @psalm-suppress PossiblyUndefinedArrayOffset */ |
||
35 | 40 | return $_SERVER['REQUEST_METHOD']; |
|
36 | } |
||
37 | |||
38 | 39 | public static function path(): string |
|
44 | 39 | ); |
|
45 | } |
||
46 | |||
47 | public function get(string $key): mixed |
||
50 | } |
||
51 | } |
||
52 |