diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d843b7..51632af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Cherry-response Changelog -## [v1.0.0](https://github.com/ABGEO07/cherry-response/releases/tag/v1.0.0 "v1.0.0") (2019-03-25) +## [v1.0.1](https://github.com/ABGEO07/cherry-response/releases/tag/v1.0.1 "v1.0.1") (2019-03-28) + +- Change Namespace + + Now you should use new namespace `Cherry\HttpUtils\Response` + +- 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-response/releases/tag/v1.0.0 "v1.0.0") (2019-02-25) #### The first stable version - Package available on: `composer require cherry-project/response` diff --git a/README.md b/README.md index 7e00033..37b8462 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ require_once __DIR__ . '/vendor/autoload.php'; ## Class Request Import class ```php -use Cherry\Response; +use Cherry\HttpUtils\Response; ``` Crete class new object ```php diff --git a/examples/test.php b/examples/test.php index 4f31f20..57cc0bf 100644 --- a/examples/test.php +++ b/examples/test.php @@ -3,7 +3,7 @@ //Include autoloader require_once __DIR__ . '/../vendor/autoload.php'; -use Cherry\Response; +use Cherry\HttpUtils\Response; //Send Response $response = new Response(); diff --git a/src/Response.php b/src/HttpUtils/Response.php similarity index 73% rename from src/Response.php rename to src/HttpUtils/Response.php index 1873380..ac1ed7f 100644 --- a/src/Response.php +++ b/src/HttpUtils/Response.php @@ -1,22 +1,37 @@ + * @license https://github.com/ABGEO07/cherry-response/blob/master/LICENSE MIT + * @link https://github.com/ABGEO07/cherry-response + */ -namespace Cherry; +namespace Cherry\HttpUtils; /** * Cherry project response class * - * @package Cherry - * @author Temuri Takalandze(ABGEO) + * @category Library + * @package Cherry + * @author Temuri Takalandze + * @license https://github.com/ABGEO07/cherry-response/blob/master/LICENSE MIT + * @link https://github.com/ABGEO07/cherry-response */ class Response { /** * Get http status code full text * - * @param $statusCode + * @param int $statusCode HTTP Status Code + * * @return string */ - private function getStatusCodeMsg($statusCode) + private function _getStatusCodeMsg($statusCode) { $msg = array( 100 => 'Continue', @@ -101,33 +116,41 @@ private function getStatusCodeMsg($statusCode) /** * Set HTTP Headers * - * @param $statusCode - * @param $headers + * @param int $statusCode HTTP Status Code + * @param array $headers HTTP Headers + * + * @return void */ - private function setHTTPHeaders($statusCode, $headers) + private function _setHTTPHeaders($statusCode, $headers) { //Set HTTP Version and status header - header("{$_SERVER['SERVER_PROTOCOL']} {$statusCode} {$this->getStatusCodeMsg($statusCode)}"); + header( + "{$_SERVER['SERVER_PROTOCOL']} {$statusCode} ". + "{$this->_getStatusCodeMsg($statusCode)}" + ); + //Set other headers - foreach ($headers as $k => $v) + foreach ($headers as $k => $v) { header("{$k}: $v"); + } } /** * Send Response. * - * @param $content - * @param int $statusCode - * @param array $headers + * @param string $content Content value + * @param int $statusCode HTTP Status Code + * @param array $headers HTTP Headers * * @return mixed */ public function sendResponse($content, $statusCode = 200, $headers = []) { - if ($content == '' || $content == null) + if ($content == '' || $content == null) { die('Set response content!'); + } - $this->setHTTPHeaders($statusCode, $headers); + $this->_setHTTPHeaders($statusCode, $headers); return $content; }