@@ -22,31 +22,15 @@ class FestivalsApiClient
2222 const BASE_URL = 'https://api.edinburghfestivalcity.com ' ;
2323 const EVENTS_ENDPOINT = '/events ' ;
2424
25- /**
26- * @var string
27- */
28- protected $ access_key ;
25+ protected string $ access_key ;
2926
30- /**
31- * @var string
32- */
33- protected $ base_url ;
27+ protected string $ base_url ;
3428
35- /**
36- * @var Client
37- */
38- protected $ guzzle ;
29+ protected Client $ guzzle ;
3930
40- /**
41- * @var string
42- */
43- protected $ secret ;
31+ protected string $ secret ;
4432
45- /**
46- * @param Client $guzzle
47- * @param string $base_url
48- */
49- public function __construct (Client $ guzzle , $ base_url = self ::BASE_URL )
33+ public function __construct (Client $ guzzle , string $ base_url = self ::BASE_URL )
5034 {
5135 $ this ->guzzle = $ guzzle ;
5236 $ this ->setBaseUrl ($ base_url );
@@ -55,9 +39,6 @@ public function __construct(Client $guzzle, $base_url = self::BASE_URL)
5539 /**
5640 * Load a single event by ID or throw if not found
5741 *
58- * @param string $id
59- *
60- * @return SingleEventResult
6142 * @throws GuzzleException
6243 * @throws FestivalsApiClientException if event not found
6344 */
@@ -75,9 +56,6 @@ public function loadEvent(string $id): SingleEventResult
7556 /**
7657 * Search API for events matching query
7758 *
78- * @param array $query
79- *
80- * @return EventSearchResult
8159 * @throws FestivalsApiClientException
8260 * @throws GuzzleException
8361 */
@@ -98,29 +76,17 @@ public function searchEvents(array $query): EventSearchResult
9876 return new EventSearchResult ($ events , (string ) $ request ->getUri (), $ total_results );
9977 }
10078
101- /**
102- * @param string $base_url
103- */
10479 public function setBaseUrl (string $ base_url ): void
10580 {
10681 $ this ->base_url = rtrim ($ base_url , '/ ' );
10782 }
10883
109- /**
110- * @param string $access_key
111- * @param string $secret
112- */
11384 public function setCredentials (string $ access_key , string $ secret ): void
11485 {
11586 $ this ->access_key = $ access_key ;
11687 $ this ->secret = $ secret ;
11788 }
11889
119- /**
120- * @param string $url
121- *
122- * @return Request
123- */
12490 protected function createRequest (string $ url ): Request
12591 {
12692 $ full_url = $ this ->base_url .$ this ->getSignedUrl ($ url );
@@ -129,12 +95,6 @@ protected function createRequest(string $url): Request
12995 return $ request ;
13096 }
13197
132- /**
133- * @param ResponseInterface $response
134- *
135- * @return array
136- * @throws FestivalsApiClientException if JSON decode failed
137- */
13898 protected function decodeJsonResponse (ResponseInterface $ response ): array
13999 {
140100 try {
@@ -144,24 +104,13 @@ protected function decodeJsonResponse(ResponseInterface $response): array
144104 }
145105 }
146106
147- /**
148- * Get signature for $data string
149- *
150- * @param string $data
151- *
152- * @return string
153- */
154107 protected function getSignature (string $ data ): string
155108 {
156109 return hash_hmac ('sha1 ' , $ data , $ this ->secret );
157110 }
158111
159112 /**
160113 * Calculate signature and append it to the URL
161- *
162- * @param string $url
163- *
164- * @return string
165114 */
166115 protected function getSignedUrl (string $ url ): string
167116 {
@@ -177,11 +126,9 @@ protected function getSignedUrl(string $url): string
177126 }
178127
179128 /**
180- * @param BadResponseException $e
181- *
182129 * @throws FestivalsApiClientException
183130 */
184- protected function handleApiError ($ e ): void
131+ protected function handleApiError (BadResponseException $ e ): void
185132 {
186133 $ msg = $ e ->getResponse ()->getBody ();
187134 $ code = $ e ->getResponse ()->getStatusCode ();
@@ -200,10 +147,6 @@ protected function handleApiError($e): void
200147 }
201148
202149 /**
203- * @param Request $request
204- *
205- * @return ResponseInterface
206- *
207150 * @throws GuzzleException
208151 * @throws FestivalsApiClientException
209152 */
0 commit comments