diff --git a/CHANGELOG.md b/CHANGELOG.md index ecbab1a..53f6a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ hiqdev/yii2-hiart ----------------- +## [Under development] + +- Implemented cURL transport ([@SilverFire]) +- Refactored exceptions ([@SilverFire]) +- Improved PHPDocs, refactored many different methods, other minor enhancements equestErrorException ([@SilverFire], [@hiqsol]) + ## [0.1.0] - 2017-01-25 - Changed nearly everything: **REDONE** to be usable for any API ([@hiqsol]) @@ -63,7 +69,7 @@ hiqdev/yii2-hiart [andreyklochok@gmail.com]: https://github.com/tafid [@BladeRoot]: https://github.com/BladeRoot [bladeroot@gmail.com]: https://github.com/BladeRoot -[Under development]: https://github.com/hiqdev/yii2-hiart/compare/0.0.4...HEAD +[Under development]: https://github.com/hiqdev/yii2-hiart/compare/0.1.0...HEAD [0.0.4]: https://github.com/hiqdev/yii2-hiart/compare/0.0.3...0.0.4 [0.0.3]: https://github.com/hiqdev/yii2-hiart/compare/0.0.2...0.0.3 [0.0.2]: https://github.com/hiqdev/yii2-hiart/compare/0.0.1...0.0.2 diff --git a/history.md b/history.md index 79d5d71..4e4e60d 100644 --- a/history.md +++ b/history.md @@ -1,6 +1,25 @@ hiqdev/yii2-hiart ----------------- +## [Under development] + +- Implemented cURL transport + - [a2a733f] 2017-01-26 Implemented cURL transport [@SilverFire] +- Refactored exceptions + - [55f40a4] 2017-01-26 Updated stream/Request::send() to follow RequestErrorException API changes [@SilverFire] + - [1780efc] 2017-01-26 Enhanced AbstractResponse::isJson to prevent warning when there is not Content-Type header available [@SilverFire] + - [9305ec8] 2017-01-26 Refactored exceptions to get rid of $errorInfo [@SilverFire] +- Improved PHPDocs, refactored many different methods, other minor enhancements equestErrorException + - [68752e3] 2017-01-26 PHPDocs updated [@SilverFire] + - [c8064d8] 2017-01-25 Minor enhancements [@SilverFire] + - [381da06] 2017-01-25 + default getStatusCode and getReasonPhrase to proxy Request [@hiqsol] + - [3aae6ec] 2017-01-25 added use of tests config [@hiqsol] + - [f81184a] 2017-01-25 Improved PHPDocs, refactored many different methods, other minor enhancements [@SilverFire] + - [2a1eefb] 2017-01-25 fixed building auth headers [@hiqsol] + - [a54f1f6] 2017-01-25 added auth headers NOT TESTED [@hiqsol] + - [938ad95] 2017-01-25 fixed sending request in DebugAction [@hiqsol] + - [3f77a7f] 2017-01-25 renamed a bit [@hiqsol] + ## [0.1.0] - 2017-01-25 - Changed nearly everything: **REDONE** to be usable for any API @@ -443,9 +462,22 @@ hiqdev/yii2-hiart [d3756e4]: https://github.com/hiqdev/yii2-hiart/commit/d3756e4 [ea50c04]: https://github.com/hiqdev/yii2-hiart/commit/ea50c04 [8047d37]: https://github.com/hiqdev/yii2-hiart/commit/8047d37 -[Under development]: https://github.com/hiqdev/yii2-hiart/compare/0.0.4...HEAD +[Under development]: https://github.com/hiqdev/yii2-hiart/compare/0.1.0...HEAD [0.0.4]: https://github.com/hiqdev/yii2-hiart/compare/0.0.3...0.0.4 [0.0.3]: https://github.com/hiqdev/yii2-hiart/compare/0.0.2...0.0.3 [0.0.2]: https://github.com/hiqdev/yii2-hiart/compare/0.0.1...0.0.2 [0.0.1]: https://github.com/hiqdev/yii2-hiart/releases/tag/0.0.1 [0.1.0]: https://github.com/hiqdev/yii2-hiart/compare/0.0.4...0.1.0 +[a2a733f]: https://github.com/hiqdev/yii2-hiart/commit/a2a733f +[55f40a4]: https://github.com/hiqdev/yii2-hiart/commit/55f40a4 +[68752e3]: https://github.com/hiqdev/yii2-hiart/commit/68752e3 +[1780efc]: https://github.com/hiqdev/yii2-hiart/commit/1780efc +[9305ec8]: https://github.com/hiqdev/yii2-hiart/commit/9305ec8 +[c8064d8]: https://github.com/hiqdev/yii2-hiart/commit/c8064d8 +[381da06]: https://github.com/hiqdev/yii2-hiart/commit/381da06 +[3aae6ec]: https://github.com/hiqdev/yii2-hiart/commit/3aae6ec +[f81184a]: https://github.com/hiqdev/yii2-hiart/commit/f81184a +[2a1eefb]: https://github.com/hiqdev/yii2-hiart/commit/2a1eefb +[a54f1f6]: https://github.com/hiqdev/yii2-hiart/commit/a54f1f6 +[938ad95]: https://github.com/hiqdev/yii2-hiart/commit/938ad95 +[3f77a7f]: https://github.com/hiqdev/yii2-hiart/commit/3f77a7f diff --git a/src/AbstractConnection.php b/src/AbstractConnection.php index 3008bf3..8949560 100644 --- a/src/AbstractConnection.php +++ b/src/AbstractConnection.php @@ -242,7 +242,7 @@ public function checkResponse(ResponseInterface $response) } /** - * Method checks whether the response is an error + * Method checks whether the response is an error. * * @param ResponseInterface $response * @return false|string the error text or boolean `false`, when the response is not an error diff --git a/src/AbstractResponse.php b/src/AbstractResponse.php index 51298a5..7f0f2b0 100644 --- a/src/AbstractResponse.php +++ b/src/AbstractResponse.php @@ -66,14 +66,14 @@ public function decodeData() } /** - * Method returns RAW request data + * Method returns RAW request data. * * @return string */ abstract public function getRawData(); /** - * Whether the request is RAW and should not be decoded + * Whether the request is RAW and should not be decoded. * @return bool */ public function isRaw() @@ -82,7 +82,7 @@ public function isRaw() } /** - * Method checks whether response is a JSON response + * Method checks whether response is a JSON response. * @return bool */ public function isJson() diff --git a/src/Exception.php b/src/Exception.php index 9e48ae8..b6b2750 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -11,7 +11,7 @@ namespace hiqdev\hiart; /** - * Class Exception represent general exception occurred in HiArt + * Class Exception represent general exception occurred in HiArt. */ class Exception extends \yii\db\Exception { diff --git a/src/RequestErrorException.php b/src/RequestErrorException.php index 995c53c..0f5d73c 100644 --- a/src/RequestErrorException.php +++ b/src/RequestErrorException.php @@ -11,7 +11,7 @@ namespace hiqdev\hiart; /** - * Class RequestErrorException represents an error occurred during the request sending + * Class RequestErrorException represents an error occurred during the request sending. */ class RequestErrorException extends Exception { @@ -28,7 +28,8 @@ class RequestErrorException extends Exception * @param int $code * @param \Exception|null $previous */ - public function __construct($message, RequestInterface $request, $code = 0, \Exception $previous = null) { + public function __construct($message, RequestInterface $request, $code = 0, \Exception $previous = null) + { $this->request = $request; parent::__construct($message, $this->getErrorInfo(), $code, $previous); } diff --git a/src/RequestInterface.php b/src/RequestInterface.php index 4e18563..7dca9e9 100644 --- a/src/RequestInterface.php +++ b/src/RequestInterface.php @@ -16,8 +16,8 @@ interface RequestInterface extends \Serializable { /** * @param array $options - * @return Response * @throws RequestErrorException + * @return Response */ public function send($options = []); @@ -32,7 +32,7 @@ public function getBody(); public function getFullUri(); /** - * Method returns the Request method in the uppercase, e.g. GET, POST, DELETE + * Method returns the Request method in the uppercase, e.g. GET, POST, DELETE. * @return string */ public function getMethod(); diff --git a/src/ResponseDecodingException.php b/src/ResponseDecodingException.php index ef64bae..db8faa7 100644 --- a/src/ResponseDecodingException.php +++ b/src/ResponseDecodingException.php @@ -1,4 +1,12 @@ response = $response; parent::__construct($message, $this->getErrorInfo(), $code, $previous); } diff --git a/src/curl/Request.php b/src/curl/Request.php index 071dddd..ed9c35b 100644 --- a/src/curl/Request.php +++ b/src/curl/Request.php @@ -15,7 +15,7 @@ use yii\helpers\ArrayHelper; /** - * Class Request represents request using cURL library + * Class Request represents request using cURL library. */ class Request extends AbstractRequest { @@ -32,8 +32,8 @@ class Request extends AbstractRequest /** * @param array $options - * @return array|mixed * @throws RequestErrorException + * @return array|mixed */ public function send($options = []) { diff --git a/src/curl/Response.php b/src/curl/Response.php index 3d9bb3c..ba4ce51 100644 --- a/src/curl/Response.php +++ b/src/curl/Response.php @@ -15,7 +15,7 @@ use hiqdev\hiart\ResponseErrorException; /** - * Class Response represents response through cURL library + * Class Response represents response through cURL library. */ class Response extends AbstractResponse { @@ -40,11 +40,11 @@ class Response extends AbstractResponse protected $reasonPhrase; /** - * Response constructor + * Response constructor. * * @param AbstractRequest $request - * @param string $rawBody the raw response, returned by `curl_exec()` method. - * @param array $info the cURL information, returned by `curl_getinfo()` method. + * @param string $rawBody the raw response, returned by `curl_exec()` method + * @param array $info the cURL information, returned by `curl_getinfo()` method * @param string $error the cURL error message, if present. Empty string otherwise. * @param int $errorCode the cURL error code, if present. Integer `0` otherwise. * @throws ResponseErrorException @@ -80,7 +80,7 @@ public function getHeader($name) } /** - * @inheritdoc + * {@inheritdoc} */ public function getStatusCode() { @@ -88,7 +88,7 @@ public function getStatusCode() } /** - * @inheritdoc + * {@inheritdoc} */ public function getReasonPhrase() { @@ -96,15 +96,15 @@ public function getReasonPhrase() } /** - * Parses raw response and returns parsed information + * Parses raw response and returns parsed information. * * @param string $data the raw response * @param array $info the curl information (result of `gurl_getinfo` call) - * @return array Array with the following keys will be returned: + * @return array array with the following keys will be returned: * - data: string, response data; * - headers: array, response headers; * - statusCode: string, the response status-code; - * - reasonPhrase: string, the response reason phrase (OK, NOT FOUND, etc). + * - reasonPhrase: string, the response reason phrase (OK, NOT FOUND, etc) */ protected function parseRawResponse($data, $info) { @@ -117,11 +117,11 @@ protected function parseRawResponse($data, $info) // First line is status-code HTTP/1.1 200 OK list(, $result['statusCode'], $result['reasonPhrase']) = explode(' ', array_shift($rawHeaders), 3); foreach ($rawHeaders as $line) { - if ($line == '') { + if ($line === '') { continue; } - list ($key, $value) = explode(': ', $line); + list($key, $value) = explode(': ', $line); $result['headers'][$key][] = $value; } @@ -129,7 +129,7 @@ protected function parseRawResponse($data, $info) } /** - * Checks $error and $errorCode for transport errors + * Checks $error and $errorCode for transport errors. * * @param string $error the cURL error message, if present. Empty string otherwise. * @param int $errorCode the cURL error code, if present. Integer `0` otherwise. diff --git a/src/rest/Connection.php b/src/rest/Connection.php index bbc9dcc..935cce6 100644 --- a/src/rest/Connection.php +++ b/src/rest/Connection.php @@ -10,7 +10,6 @@ namespace hiqdev\hiart\rest; -use hiqdev\hiart\ResponseErrorException; use hiqdev\hiart\ResponseInterface; class Connection extends \hiqdev\hiart\AbstractConnection @@ -18,7 +17,7 @@ class Connection extends \hiqdev\hiart\AbstractConnection public $queryBuilderClass = QueryBuilder::class; /** - * Method checks whether the response is an error + * Method checks whether the response is an error. * * @param ResponseInterface $response * @return false|string the error text or boolean `false`, when the response is not an error @@ -31,6 +30,5 @@ public function getResponseError(ResponseInterface $response) } return $response->getReasonPhrase(); - } } diff --git a/src/stream/Request.php b/src/stream/Request.php index 4c535ae..938f966 100644 --- a/src/stream/Request.php +++ b/src/stream/Request.php @@ -35,8 +35,8 @@ class Request extends AbstractRequest /** * @param array $options - * @return mixed * @throws RequestErrorException + * @return mixed */ public function send($options = []) {