Skip to content

Commit

Permalink
Utilise new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
craig410 committed Oct 25, 2022
1 parent b9b9276 commit 1845463
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/EventSearchIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

class EventSearchIterator implements IteratorAggregate
{
protected FestivalsApiClient $client;

protected EventSearchResult $last_result;

Expand All @@ -28,9 +27,8 @@ class EventSearchIterator implements IteratorAggregate

protected int $request_count = 0;

public function __construct(FestivalsApiClient $client)
public function __construct(protected FestivalsApiClient $client)
{
$this->client = $client;
}

/**
Expand Down
10 changes: 3 additions & 7 deletions src/FestivalsApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ class FestivalsApiClient

protected string $base_url;

protected Client $guzzle;

protected string $secret;

public function __construct(Client $guzzle, string $base_url = self::BASE_URL)
public function __construct(protected Client $guzzle, string $base_url = self::BASE_URL)
{
$this->guzzle = $guzzle;
$this->setBaseUrl($base_url);
}

Expand Down Expand Up @@ -90,9 +87,8 @@ public function setCredentials(string $access_key, string $secret): void
protected function createRequest(string $url): Request
{
$full_url = $this->base_url.$this->getSignedUrl($url);
$request = new Request('GET', $full_url);

return $request;
return new Request('GET', $full_url);
}

protected function decodeJsonResponse(ResponseInterface $response): array
Expand All @@ -114,7 +110,7 @@ protected function getSignature(string $data): string
*/
protected function getSignedUrl(string $url): string
{
if (strpos($url, '?') !== FALSE) {
if (str_contains($url, '?')) {
$url .= '&key='.$this->access_key;
} else {
$url .= '?key='.$this->access_key;
Expand Down
8 changes: 2 additions & 6 deletions src/FestivalsApiClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@

class FestivalsApiClientException extends RuntimeException
{

protected ?string $url;

public function __construct(
string $message,
?int $code = NULL,
?string $url = NULL,
int $code = 0,
protected ?string $url = NULL,
?Exception $previous_exception = NULL
) {
parent::__construct($message, $code, $previous_exception);
$this->url = $url;
}

public static function invalidJsonResponse(int $code, ?Exception $previous_exception = NULL): FestivalsApiClientException
Expand Down

0 comments on commit 1845463

Please sign in to comment.