From 3776ab80f23c07943d2228f2975e515c494f930a Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 2 Jan 2024 20:39:07 +0100 Subject: improve Request query access and add special input query parameter --- src/Request.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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; + } } -- cgit v1.2.3