diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c56cdd..66b22a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Cherry-request Changelog -## [v1.0.0](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.0 "v1.0.0") (2019-03-25) +## [v1.0.1](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.1 "v1.0.1") (2019-03-28) + +- Change Namespace + + Now you should use new namespace `Cherry\HttpUtils\Request` + +- Validate code in PHP CodeSniffer + + Code and comments has checked on [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) + +## [v1.0.0](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.0 "v1.0.0") (2019-02-25) #### The first stable version - Package available on: `composer require cherry-project/request` diff --git a/README.md b/README.md index 02161e6..4227cdf 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ require_once __DIR__ . '/vendor/autoload.php'; ## Class Request Import class ```php -use Cherry\Request; +use Cherry\HttpUtils\Request; ``` Crete class new object ```php diff --git a/examples/test.php b/examples/test.php index 60bcd9f..91b2aaf 100644 --- a/examples/test.php +++ b/examples/test.php @@ -3,7 +3,7 @@ //Include autoloader require_once __DIR__ . '/../vendor/autoload.php'; -use Cherry\Request; +use Cherry\HttpUtils\Request; $request = new Request(); diff --git a/src/Request.php b/src/HttpUtils/Request.php similarity index 69% rename from src/Request.php rename to src/HttpUtils/Request.php index d876043..1b43a85 100644 --- a/src/Request.php +++ b/src/HttpUtils/Request.php @@ -1,12 +1,26 @@ + * @license https://github.com/ABGEO07/cherry-request/blob/master/LICENSE MIT + * @link https://github.com/ABGEO07/cherry-request + */ -namespace Cherry; +namespace Cherry\HttpUtils; /** * Cherry project request class * - * @package Cherry - * @author Temuri Takalandze(ABGEO) + * @category Library + * @package Cherry + * @author Temuri Takalandze + * @license https://github.com/ABGEO07/cherry-request/blob/master/LICENSE MIT + * @link https://github.com/ABGEO07/cherry-request */ class Request @@ -14,7 +28,8 @@ class Request /** * Get request HTTP headers * - * @param null|array|string $key + * @param null|array|string $key Searched key or array of keys + * * @return array|string */ public function getHeaders($key = null) @@ -27,17 +42,21 @@ public function getHeaders($key = null) $value = isset($headers[$k]) ? $headers[$k] : null; $return[$k] = $value; } - } else + } else { $return = isset($headers[$key]) ? $headers[$key] : null; - } else + } + } else { $return = $headers; + } + return $return; } /** * Check if request has header * - * @param $key + * @param string $key Http header for searching + * * @return bool */ public function hasHeader($key) @@ -72,7 +91,8 @@ public function getPath() */ function getScheme() { - return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://'; + return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? + 'https://' : 'http://'; } /** @@ -95,14 +115,17 @@ function getQueryParams() /** * Get request query parameter by key * - * @param $key + * @param string $key Query parameter name + * * @return string|null */ function getQuery($key) { $queryArray = $this->getQueryParams(); - if (isset($queryArray[$key])) + if (isset($queryArray[$key])) { return $queryArray[$key]; + } + return null; } @@ -115,10 +138,12 @@ function getData() { $method = $this->getMethod(); $return = null; - if ($method == 'GET') + if ($method == 'GET') { $return = $_GET; - else if ($method == 'POST') + } else if ($method == 'POST') { $return = $_POST; + } + return $return; } } \ No newline at end of file