diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-02 20:39:07 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-02 20:39:07 +0100 |
commit | 3776ab80f23c07943d2228f2975e515c494f930a (patch) | |
tree | 23dddc6a2a42330c4ec5470069ab8bad63fa9550 /src/Request.php | |
parent | 2d814b1e433ae96b36579b2fa882e9a17652e7a5 (diff) |
improve Request query access and add special input query parameterv1.1.0
Diffstat (limited to 'src/Request.php')
-rw-r--r-- | src/Request.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Request.php b/src/Request.php index 586134d..ceb7dbb 100644 --- a/src/Request.php +++ b/src/Request.php @@ -21,7 +21,12 @@ class Request if (isset($requestUrl['query'])) { foreach (explode('&', $requestUrl['query']) as $queryString) { $query = explode('=', $queryString); - $this->query[$query[0]] = $query[1] ?? null; + + if (empty($query[1])) { + $this->query['input'] = $query[0]; + } else { + $this->query[$query[0]] = $query[1]; + } } } } @@ -45,4 +50,21 @@ class Request { return $this->path; } + + public function getQuery(): array + { + return $this->query; + } + + public function get(string $key): mixed + { + return $this->query[$key] ?? null; + } + + public function set(string $key, string $value): self + { + $this->query[$key] = $value; + + return $this; + } } |