From e2ba6bd46ec5e3136f46bb4726718af2cec33249 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Tue, 21 Oct 2025 15:55:49 +0300 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=90=D0=BD=D0=BD=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BA=20=D1=82=D0=B8=D0=BF=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Collection.php | 24 ++++++++++++++---------- src/HttpRequest.php | 7 ++++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 027eb30..b15f3c0 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -7,12 +7,8 @@ namespace ctiso; */ class Collection implements \ArrayAccess { - /** - * Holds collective request data - * - * @var array - */ - protected $data = array(); + /** @var array */ + protected $data = []; /** * Преобразование массива в коллекцию @@ -34,8 +30,7 @@ class Collection implements \ArrayAccess } /** - * Store "request data" in GPC order. - * + * @param string $key * @param mixed $value * @@ -50,7 +45,6 @@ class Collection implements \ArrayAccess * Read stored "request data" by referencing a key. * * @param string $key - * * @return mixed */ public function get($key, $default = null) @@ -58,12 +52,22 @@ class Collection implements \ArrayAccess return isset($this->data[$key]) && $this->data[$key] != '' ? $this->data[$key] : $default; } + /** + * @param string $key + * @param int $default + * @return int + */ public function getInt($key, $default = 0) { return (int)$this->get($key, $default); } - public function getString($key, $default = '') + /** + * @param string $key + * @param string $default + * @return string + */ + public function getString(string $key, string $default = ''): string { return (string)$this->get($key, $default); } diff --git a/src/HttpRequest.php b/src/HttpRequest.php index 35b6529..b3fb8a3 100644 --- a/src/HttpRequest.php +++ b/src/HttpRequest.php @@ -48,7 +48,7 @@ class HttpRequest extends Collection } /** - * @param T $key + * @param string $key * @return mixed */ function get($key, $default = null) @@ -56,6 +56,11 @@ class HttpRequest extends Collection return parent::get('data')->get($key, $default); } + function getString(string $key, string $default = ''): string + { + return parent::get('data')->getString($key, $default); + } + function session(?Session $value = null) { if ($value) {