diff options
Diffstat (limited to 'lib/http.php')
-rw-r--r-- | lib/http.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/http.php b/lib/http.php index 90b65a6e..d53909b4 100644 --- a/lib/http.php +++ b/lib/http.php @@ -166,6 +166,46 @@ final class CurlHttpClient implements HttpClient } } +final class Request +{ + private array $get; + private array $server; + + private function __construct() + { + } + + public static function fromGlobals(): self + { + $self = new self(); + $self->get = $_GET; + $self->server = $_SERVER; + return $self; + } + + public static function fromCli(array $cliArgs): self + { + $self = new self(); + $self->get = $cliArgs; + return $self; + } + + public function get(string $key, $default = null): ?string + { + return $this->get[$key] ?? $default; + } + + public function server(string $key, string $default = null): ?string + { + return $this->server[$key] ?? $default; + } + + public function toArray(): array + { + return $this->get; + } +} + final class Response { public const STATUS_CODES = [ |