diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
| commit | fa1bccd968647f6ab5cce0ec4293b39c6fde7633 (patch) | |
| tree | a51b489a43bdfcc2688bd0855cf3e32382ad958c /classes/Request.php | |
| parent | ab7702f0e3dd63bdeaea3cb6db138878774c3b47 (diff) | |
| download | the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.gz the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.xz | |
spaces to tabs
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; + } } |
