@@ -55,10 +55,10 @@ |
||
55 | 55 | public function __construct( |
56 | 56 | string $method, |
57 | 57 | string $endpoint, |
58 | - ?string $element, |
|
58 | + ? string $element, |
|
59 | 59 | array $acceptableMIMETypes, |
60 | - ?string $version, |
|
61 | - ?string $apiKey, |
|
60 | + ? string $version, |
|
61 | + ? string $apiKey, |
|
62 | 62 | array $queryData, |
63 | 63 | $data |
64 | 64 | ) { |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param array $acceptableMIMETypes |
38 | 38 | * @param null|string $queryString |
39 | 39 | */ |
40 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
40 | + public function __construct(string $endpoint, ? string $element, ? string $version, ? string $apiKey, array $acceptableMIMETypes, ? string $queryString) |
|
41 | 41 | { |
42 | 42 | $this->endpoint = $endpoint; |
43 | 43 | $this->element = $element; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | { |
48 | 48 | foreach ($headers as $key => $values) { |
49 | 49 | if (strtolower($key) == strtolower($this->apiKeyHeaderKey)) { |
50 | - foreach($values as $value) { |
|
50 | + foreach ($values as $value) { |
|
51 | 51 | return $value; |
52 | 52 | } |
53 | 53 | } |
@@ -48,12 +48,12 @@ |
||
48 | 48 | $parsedHeaders = $this->headerParser->parse($serverRequest->getHeaders()); |
49 | 49 | |
50 | 50 | $urlQueryData = []; |
51 | - if($urlQueryString = $parsedURL->getQueryString()) { |
|
51 | + if ($urlQueryString = $parsedURL->getQueryString()) { |
|
52 | 52 | parse_str($urlQueryString, $urlQueryData); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $apiKey = $parsedURL->getAPIKey(); |
56 | - if($apiKey === null) { |
|
56 | + if ($apiKey === null) { |
|
57 | 57 | $apiKey = $parsedHeaders->getAPIKey(); |
58 | 58 | } |
59 | 59 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | $this->config = parse_ini_file($filename, true); |
25 | 25 | |
26 | 26 | if ($this->config === false) { |
27 | - throw new INIParseException('Could not parse: ' . $filename, true); |
|
27 | + throw new INIParseException('Could not parse: '.$filename, true); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($responseTypes = []) |
22 | 22 | { |
23 | - foreach($responseTypes as $mimeType => $serializer) { |
|
23 | + foreach ($responseTypes as $mimeType => $serializer) { |
|
24 | 24 | $this->registerSerializer($mimeType, $serializer); |
25 | 25 | } |
26 | 26 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | foreach ($acceptedMIMETypes as $acceptedMIMEType) { |
46 | - if(isset($this->serializers[strtolower($acceptedMIMEType)])) { |
|
46 | + if (isset($this->serializers[strtolower($acceptedMIMEType)])) { |
|
47 | 47 | return new APIResponse($acceptedMIMEType, $this->serializers[strtolower($acceptedMIMEType)]->serialize($data)); |
48 | 48 | } |
49 | 49 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function register(string $name, string $version, Endpoint $endpoint) |
24 | 24 | { |
25 | - if(!isset($this->endpoints[$version])) { |
|
25 | + if (!isset($this->endpoints[$version])) { |
|
26 | 26 | $this->endpoints[$version] = []; |
27 | 27 | } |
28 | 28 | $this->endpoints[$version][strtolower($name)] = $endpoint; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public function getEndpoint(string $name, string $version): Endpoint |
38 | 38 | { |
39 | 39 | $lowercaseName = strtolower($name); |
40 | - if(!isset($this->endpoints[$version]) || !isset($this->endpoints[$version][$lowercaseName])) { |
|
41 | - throw new UnknownEndpointException('Could not find endpoint: ' . $name . ' of version: ' . $version); |
|
40 | + if (!isset($this->endpoints[$version]) || !isset($this->endpoints[$version][$lowercaseName])) { |
|
41 | + throw new UnknownEndpointException('Could not find endpoint: '.$name.' of version: '.$version); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return $this->endpoints[$version][$lowercaseName]; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } catch (InvalidAPIKeyException | AccessDeniedException $e) { |
103 | 103 | $this->logCaughtThrowableResultingInHTTPCode(403, $e, LogLevel::NOTICE); |
104 | 104 | return $response->withStatus(403, "Access Denied"); |
105 | - } catch (ElementConflictException $e) { |
|
105 | + } catch (ElementConflictException $e) { |
|
106 | 106 | $this->logCaughtThrowableResultingInHTTPCode(409, $e, LogLevel::NOTICE); |
107 | 107 | return $response->withStatus(409, "Conflict"); |
108 | 108 | } catch (ThrottleLimitExceededException $e) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $body = $response->getBody(); |
138 | - while(!$body->eof()) { |
|
138 | + while (!$body->eof()) { |
|
139 | 139 | echo $body->read(1024); |
140 | 140 | } |
141 | 141 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $method = $this->mapEndpointMethod($request); |
60 | 60 | if (!method_exists($endpoint, $method)) { |
61 | - throw new MethodNotFoundException("The endpoint method " . $method . " was not found"); |
|
61 | + throw new MethodNotFoundException("The endpoint method ".$method." was not found"); |
|
62 | 62 | } |
63 | 63 | return call_user_func([$endpoint, $method], $request); |
64 | 64 | } |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function mapEndpointMethod(APIRequest $request): string |
71 | 71 | { |
72 | - return strtolower($request->getMethod()) . (!$request->getElement() ? 'All': ''); |
|
72 | + return strtolower($request->getMethod()).(!$request->getElement() ? 'All' : ''); |
|
73 | 73 | } |
74 | 74 | } |