Skip to content

Commit

Permalink
Merge pull request #38 from kleisauke/cleanup
Browse files Browse the repository at this point in the history
Cleanup / fixes
  • Loading branch information
IcyApril authored Nov 25, 2017
2 parents c8e85d2 + ff42f33 commit d00a1d3
Show file tree
Hide file tree
Showing 33 changed files with 232 additions and 289 deletions.
25 changes: 13 additions & 12 deletions src/Adapter/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,56 @@ interface Adapter
* Adapter constructor.
*
* @param Auth $auth
* @param String $baseURI
* @param string $baseURI
*/
public function __construct(Auth $auth, String $baseURI);
public function __construct(Auth $auth, string $baseURI);

/**
* Sends a GET request.
* Per Robustness Principle - not including the ability to send a body with a GET request (though possible in the
* RFCs, it is never useful).
*
* @param String $uri
* @param string $uri
* @param array $query
* @param array $headers
*
* @return mixed
*/
public function get(String $uri, array $query, array $headers): ResponseInterface;
public function get(string $uri, array $query, array $headers): ResponseInterface;

/**
* @param String $uri
* @param string $uri
* @param array $headers
* @param array $body
*
* @return mixed
*/
public function post(String $uri, array $headers, array $body): ResponseInterface;
public function post(string $uri, array $headers, array $body): ResponseInterface;

/**
* @param String $uri
* @param string $uri
* @param array $headers
* @param array $body
*
* @return mixed
*/
public function put(String $uri, array $headers, array $body): ResponseInterface;
public function put(string $uri, array $headers, array $body): ResponseInterface;

/**
* @param String $uri
* @param string $uri
* @param array $headers
* @param array $body
*
* @return mixed
*/
public function patch(String $uri, array $headers, array $body): ResponseInterface;
public function patch(string $uri, array $headers, array $body): ResponseInterface;

/**
* @param String $uri
* @param string $uri
* @param array $headers
* @param array $body
*
* @return mixed
*/
public function delete(String $uri, array $headers, array $body): ResponseInterface;
public function delete(string $uri, array $headers, array $body): ResponseInterface;
}
20 changes: 9 additions & 11 deletions src/Adapter/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Guzzle implements Adapter
/**
* @inheritDoc
*/
public function __construct(Auth $auth, String $baseURI = null)
public function __construct(Auth $auth, string $baseURI = null)
{
if ($baseURI === null) {
$baseURI = "https://api.cloudflare.com/client/v4/";
$baseURI = 'https://api.cloudflare.com/client/v4/';
}

$headers = $auth->getHeaders();
Expand All @@ -37,7 +37,7 @@ public function __construct(Auth $auth, String $baseURI = null)
/**
* @inheritDoc
*/
public function get(String $uri, array $query = [], array $headers = []): ResponseInterface
public function get(string $uri, array $query = [], array $headers = []): ResponseInterface
{
$response = $this->client->get($uri, ['query' => $query, 'headers' => $headers]);

Expand All @@ -48,7 +48,7 @@ public function get(String $uri, array $query = [], array $headers = []): Respon
/**
* @inheritDoc
*/
public function post(String $uri, array $headers = [], array $body = []): ResponseInterface
public function post(string $uri, array $headers = [], array $body = []): ResponseInterface
{
$response = $this->client->post(
$uri,
Expand All @@ -65,7 +65,7 @@ public function post(String $uri, array $headers = [], array $body = []): Respon
/**
* @inheritDoc
*/
public function put(String $uri, array $headers = [], array $body = []): ResponseInterface
public function put(string $uri, array $headers = [], array $body = []): ResponseInterface
{
$response = $this->client->put(
$uri,
Expand All @@ -82,7 +82,7 @@ public function put(String $uri, array $headers = [], array $body = []): Respons
/**
* @inheritDoc
*/
public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface
public function patch(string $uri, array $headers = [], array $body = []): ResponseInterface
{
$response = $this->client->patch(
$uri,
Expand All @@ -99,7 +99,7 @@ public function patch(String $uri, array $headers = [], array $body = []): Respo
/**
* @inheritDoc
*/
public function delete(String $uri, array $headers = [], array $body = []): ResponseInterface
public function delete(string $uri, array $headers = [], array $body = []): ResponseInterface
{
$response = $this->client->delete(
$uri,
Expand All @@ -122,13 +122,11 @@ private function checkError(ResponseInterface $response)
}

if (isset($json->errors)) {
foreach ($json->errors as $error) {
throw new ResponseException($error->message, $error->code);
}
throw new ResponseException($json->errors[0]->message, $json->errors[0]->code);
}

if (isset($json->success) && ($json->success === false)) {
throw new ResponseException("Request was unsuccessful.");
throw new ResponseException('Request was unsuccessful.');
}
}
}
2 changes: 1 addition & 1 deletion src/Auth/APIKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class APIKey implements Auth
private $email;
private $apiKey;

public function __construct(String $email, String $apiKey)
public function __construct(string $email, string $apiKey)
{
$this->email = $email;
$this->apiKey = $apiKey;
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/UserServiceKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class UserServiceKey implements Auth
{
private $userServiceKey;

public function __construct(String $userServiceKey)
public function __construct(string $userServiceKey)
{
$this->userServiceKey = $userServiceKey;
}
Expand Down
Loading

0 comments on commit d00a1d3

Please sign in to comment.