Skip to content

Commit

Permalink
csfixed
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Jan 26, 2017
1 parent a2a733f commit 951ae15
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 31 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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])
Expand Down Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion history.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
5 changes: 3 additions & 2 deletions src/RequestErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface RequestInterface extends \Serializable
{
/**
* @param array $options
* @return Response
* @throws RequestErrorException
* @return Response
*/
public function send($options = []);

Expand All @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/ResponseDecodingException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Tools to use API as ActiveRecord for Yii2
*
* @link https://github.com/hiqdev/yii2-hiart
* @package yii2-hiart
* @license BSD-3-Clause
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
*/

namespace hiqdev\hiart;

Expand Down
5 changes: 3 additions & 2 deletions src/ResponseErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ class ResponseErrorException extends Exception
protected $response;

/**
* ResponseErrorException constructor
* ResponseErrorException constructor.
*
* @param string $message the error message
* @param ResponseInterface $response
* @param int $code
* @param \Exception|null $previous
*/
public function __construct($message, ResponseInterface $response, $code = 0, \Exception $previous = null) {
public function __construct($message, ResponseInterface $response, $code = 0, \Exception $previous = null)
{
$this->response = $response;
parent::__construct($message, $this->getErrorInfo(), $code, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions src/curl/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -32,8 +32,8 @@ class Request extends AbstractRequest

/**
* @param array $options
* @return array|mixed
* @throws RequestErrorException
* @return array|mixed
*/
public function send($options = [])
{
Expand Down
24 changes: 12 additions & 12 deletions src/curl/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down Expand Up @@ -80,31 +80,31 @@ public function getHeader($name)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getStatusCode()
{
return $this->statusCode;
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getReasonPhrase()
{
return $this->reasonPhrase;
}

/**
* 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)
{
Expand All @@ -117,19 +117,19 @@ 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;
}

return $result;
}

/**
* 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.
Expand Down
4 changes: 1 addition & 3 deletions src/rest/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

namespace hiqdev\hiart\rest;

use hiqdev\hiart\ResponseErrorException;
use hiqdev\hiart\ResponseInterface;

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
Expand All @@ -31,6 +30,5 @@ public function getResponseError(ResponseInterface $response)
}

return $response->getReasonPhrase();

}
}
2 changes: 1 addition & 1 deletion src/stream/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Request extends AbstractRequest

/**
* @param array $options
* @return mixed
* @throws RequestErrorException
* @return mixed
*/
public function send($options = [])
{
Expand Down

0 comments on commit 951ae15

Please sign in to comment.