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) {