Skip to content

Commit

Permalink
Reformat code.
Browse files Browse the repository at this point in the history
  • Loading branch information
PATROMO committed Jul 24, 2020
1 parent c263a61 commit 40b5474
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
20 changes: 11 additions & 9 deletions src/Client.php
Expand Up @@ -7,13 +7,13 @@

class Client
{
/** @var Endpoint */
/** @var Endpoint */
private $endpoint;

/** @var HttpClientInterface */
private $httpClient;

/** @var string[] */
/** @var string[] */
private $headers;

public function __construct(Endpoint $endpoint, HttpClientInterface $httpClient = null, array $headers = [])
Expand All @@ -27,22 +27,24 @@ public function __construct(Endpoint $endpoint, HttpClientInterface $httpClient
}
}


/**
* @param string $method
* @param string $uri
* @param string $method
* @param string $uri
* @param array|null $body
* @param bool $raw
*
* @return mixed
* @return mixed|string
*/
public function request($method, $uri = '', array $body = null, $raw = false)
{
$request = new Request(
(string)$method,
(string)$uri,
array_merge([
'Content-Type' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->endpoint->getApiKey(),
'User-Agent' => 'easybill-php-sdk (rest-master)'
'User-Agent' => 'easybill-php-sdk (rest-master)',
], $this->headers),
is_array($body) ? json_encode($body) : null
);
Expand All @@ -60,9 +62,9 @@ public function request($method, $uri = '', array $body = null, $raw = false)
private function send(RequestInterface $request)
{
return $this->httpClient->send($request, [
'base_uri' => $this->endpoint->getHost(),
'base_uri' => $this->endpoint->getHost(),
'http_errors' => true,
'timeout' => 30
'timeout' => 30,
]);
}
}
4 changes: 2 additions & 2 deletions src/Endpoint.php
Expand Up @@ -2,10 +2,10 @@

class Endpoint
{
/** @var string */
/** @var string */
private $apiKey;

/** @var string */
/** @var string */
private $host;

/**
Expand Down
7 changes: 6 additions & 1 deletion src/HttpClient/BaseHttpClient.php
Expand Up @@ -10,11 +10,16 @@ class BaseHttpClient implements HttpClientInterface
/** @var HttpClientInterface */
private $httpClient;

/** @var int */
private $maxApiCallsPerMinute;

/** @var array int[] */
private $apiCalls = [];

/**
* @param \easybill\SDK\HttpClientInterface $httpClient
* @param int $maxApiCallsPerMinute
*/
public function __construct(HttpClientInterface $httpClient, $maxApiCallsPerMinute = 60)
{
$this->httpClient = $httpClient;
Expand All @@ -23,7 +28,7 @@ public function __construct(HttpClientInterface $httpClient, $maxApiCallsPerMinu

/**
* @param \Psr\Http\Message\RequestInterface $request
* @param array $options
* @param array $options
*
* @return \Psr\Http\Message\ResponseInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient/GuzzleHttpClient.php
Expand Up @@ -9,7 +9,7 @@ class GuzzleHttpClient implements HttpClientInterface

/**
* @param \Psr\Http\Message\RequestInterface $request
* @param array $options
* @param array $options
*
* @return \Psr\Http\Message\ResponseInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClientInterface.php
Expand Up @@ -6,7 +6,7 @@ interface HttpClientInterface
{
/**
* @param \Psr\Http\Message\RequestInterface $request
* @param array $options
* @param array $options
*
* @return \Psr\Http\Message\ResponseInterface
*/
Expand Down

0 comments on commit 40b5474

Please sign in to comment.