diff options
Diffstat (limited to 'classes/Request.php')
| -rw-r--r-- | classes/Request.php | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/classes/Request.php b/classes/Request.php index b3d2b62..d337740 100644 --- a/classes/Request.php +++ b/classes/Request.php @@ -2,56 +2,56 @@ class Request { - /** @var array<string, mixed> */ - private array $serverParams; - /** @var array<string, mixed> */ - private array $queryParams; - /** @var array<string, mixed> */ - private array $bodyParams; - /** @var array<string, mixed> */ - private array $cookies; - - public function __construct() - { - $this->serverParams = $_SERVER; - $this->queryParams = $_GET; - $this->bodyParams = $_POST; - $this->cookies = $_COOKIE; - } - - /** @return array<string, mixed> */ - public function getServerParams(): array - { - return $this->serverParams; - } - - /** @return array<string, mixed> */ - public function getQueryParams(): array - { - return $this->queryParams; - } - - /** @return array<string, mixed> */ - public function getParsedBody(): array - { - return array_merge($this->queryParams, $this->bodyParams); - } - - /** @return array<string, mixed> */ - public function getCookieParams(): array - { - return $this->cookies; - } - - public function getAttribute(string $name, mixed $default = null): mixed - { - return $this->getParsedBody()[$name] ?? $default; - } - - public function withAttribute(string $name, mixed $value): self - { - $clone = clone $this; - $clone->bodyParams[$name] = $value; - return $clone; - } + /** @var array<string, mixed> */ + private array $serverParams; + /** @var array<string, mixed> */ + private array $queryParams; + /** @var array<string, mixed> */ + private array $bodyParams; + /** @var array<string, mixed> */ + private array $cookies; + + public function __construct() + { + $this->serverParams = $_SERVER; + $this->queryParams = $_GET; + $this->bodyParams = $_POST; + $this->cookies = $_COOKIE; + } + + /** @return array<string, mixed> */ + public function getServerParams(): array + { + return $this->serverParams; + } + + /** @return array<string, mixed> */ + public function getQueryParams(): array + { + return $this->queryParams; + } + + /** @return array<string, mixed> */ + public function getParsedBody(): array + { + return array_merge($this->queryParams, $this->bodyParams); + } + + /** @return array<string, mixed> */ + public function getCookieParams(): array + { + return $this->cookies; + } + + public function getAttribute(string $name, mixed $default = null): mixed + { + return $this->getParsedBody()[$name] ?? $default; + } + + public function withAttribute(string $name, mixed $value): self + { + $clone = clone $this; + $clone->bodyParams[$name] = $value; + return $clone; + } } |
