Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic authored and StyleCIBot committed Apr 6, 2018
1 parent c19bafc commit 7c97aba
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public function requestAsync(

$promise->then(
function (ResponseInterface $response) use ($onFullfiled) {
$this->asyncFulfilled($response, $onFullfiled);
$this->asyncFulfilled($response, $onFullfiled);
},
function (RequestException $exception) use ($onRejected) {
$this->asyncRejected($exception, $onRejected);
$this->asyncRejected($exception, $onRejected);
}
);

Expand Down Expand Up @@ -238,57 +238,57 @@ protected function parseUrl($config)

return $config;
}
/**
* Handles async request success.
*
* @param \Psr\Http\Message\ResponseInterface $response
* @param callable|null $callback
*
* @return void
*/
protected function asyncFulfilled(ResponseInterface $response, callable $callback = null)
{
$error = null;
if ($response->hasError()) {
$error = new Exceptions\BitcoindException($response->error());
}

if (is_callable($callback)) {
$callback($error ?: $response);
}
}
/**
* Handles async request failure.
*
* @param \GuzzleHttp\Exception\RequestException $exception
* @param callable|null $callback
*
* @return void
*/
protected function asyncRejected(RequestException $exception, callable $callback = null)
{
if (
$exception->hasResponse() &&
$exception->getResponse()->hasError()
) {
$exception = new Exceptions\BitcoindException(
$exception->getResponse()->error()
);
}

if ($exception instanceof RequestException) {
$exception = new Exceptions\ClientException(
$exception->getMessage(),
$exception->getCode()
);
}

if (is_callable($callback)) {
$callback($exception);
}
}

/**
* Handles async request success.
*
* @param \Psr\Http\Message\ResponseInterface $response
* @param callable|null $callback
*
* @return void
*/
protected function asyncFulfilled(ResponseInterface $response, callable $callback = null)
{
$error = null;
if ($response->hasError()) {
$error = new Exceptions\BitcoindException($response->error());
}

if (is_callable($callback)) {
$callback($error ?: $response);
}
}

/**
* Handles async request failure.
*
* @param \GuzzleHttp\Exception\RequestException $exception
* @param callable|null $callback
*
* @return void
*/
protected function asyncRejected(RequestException $exception, callable $callback = null)
{
if (
$exception->hasResponse() &&
$exception->getResponse()->hasError()
) {
$exception = new Exceptions\BitcoindException(
$exception->getResponse()->error()
);
}

if ($exception instanceof RequestException) {
$exception = new Exceptions\ClientException(
$exception->getMessage(),
$exception->getCode()
);
}

if (is_callable($callback)) {
$callback($exception);
}
}

/**
* Converts amount from satoshi to bitcoin.
Expand Down

0 comments on commit 7c97aba

Please sign in to comment.