| Total Complexity | 5 |
| Total Lines | 55 |
| 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 | public const ALL_METHODS = [ |
||
| 19 | self::METHOD_CONNECT, |
||
| 20 | self::METHOD_DELETE, |
||
| 21 | self::METHOD_GET, |
||
| 22 | self::METHOD_HEAD, |
||
| 23 | self::METHOD_OPTIONS, |
||
| 24 | self::METHOD_PATCH, |
||
| 25 | self::METHOD_POST, |
||
| 26 | self::METHOD_PUT, |
||
| 27 | self::METHOD_TRACE, |
||
| 28 | ]; |
||
| 29 | |||
| 30 | 72 | private function __construct( |
|
| 31 | private array $query, |
||
| 32 | private array $request, |
||
| 33 | private array $server, |
||
| 34 | ) { |
||
| 35 | 72 | } |
|
| 36 | |||
| 37 | 72 | public static function fromGlobals(): self |
|
| 38 | { |
||
| 39 | 72 | return new self($_GET, $_POST, $_SERVER); |
|
| 40 | } |
||
| 41 | |||
| 42 | 72 | public function isMethod(string $method): bool |
|
| 46 | } |
||
| 47 | |||
| 48 | 66 | public function path(): string |
|
| 49 | { |
||
| 50 | /** @psalm-suppress PossiblyUndefinedArrayOffset */ |
||
| 51 | 66 | return (string)parse_url( |
|
| 52 | 66 | (string)$this->server['REQUEST_URI'], |
|
| 53 | 66 | PHP_URL_PATH, |
|
| 54 | 66 | ); |
|
| 55 | } |
||
| 56 | |||
| 57 | public function get(string $key): mixed |
||
| 62 | } |
||
| 63 | } |
||
| 64 |