@@ -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 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | { |
| 58 | 58 | $item = $this->cacheItemPool->getItem($this->deriveCacheKey($request)); |
| 59 | 59 | |
| 60 | - if($requestCount = $item->get()) { |
|
| 60 | + if ($requestCount = $item->get()) { |
|
| 61 | 61 | $item->set($requestCount + 1); |
| 62 | 62 | } else { |
| 63 | 63 | $item->set(1)->expiresAfter($this->perXSeconds); |
@@ -30,6 +30,6 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | protected function deriveCacheKey(APIRequest $request): string |
| 32 | 32 | { |
| 33 | - return $this->keyPrefix . $request->getApiKey(); |
|
| 33 | + return $this->keyPrefix.$request->getApiKey(); |
|
| 34 | 34 | } |
| 35 | 35 | } |
@@ -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]; |
@@ -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 | } |
@@ -55,10 +55,10 @@ discard block |
||
| 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 | ) { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * @return null|string |
| 93 | 93 | */ |
| 94 | - public function getElement(): ?string |
|
| 94 | + public function getElement(): ? string |
|
| 95 | 95 | { |
| 96 | 96 | return $this->element; |
| 97 | 97 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * @return null|string |
| 109 | 109 | */ |
| 110 | - public function getVersion(): ?string |
|
| 110 | + public function getVersion(): ? string |
|
| 111 | 111 | { |
| 112 | 112 | return $this->version; |
| 113 | 113 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | /** |
| 116 | 116 | * @return null|string |
| 117 | 117 | */ |
| 118 | - public function getApiKey(): ?string |
|
| 118 | + public function getApiKey(): ? string |
|
| 119 | 119 | { |
| 120 | 120 | return $this->apiKey; |
| 121 | 121 | } |
@@ -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 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param array $acceptableMIMETypes |
| 43 | 43 | * @param null|string $queryString |
| 44 | 44 | */ |
| 45 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
| 45 | + public function __construct(string $endpoint, ? string $element, ? string $version, ? string $apiKey, array $acceptableMIMETypes, ? string $queryString) |
|
| 46 | 46 | { |
| 47 | 47 | $this->endpoint = $endpoint; |
| 48 | 48 | $this->element = $element; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * @return null|string |
| 65 | 65 | */ |
| 66 | - public function getElement(): ?string |
|
| 66 | + public function getElement(): ? string |
|
| 67 | 67 | { |
| 68 | 68 | return $this->element; |
| 69 | 69 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * @return null|string |
| 73 | 73 | */ |
| 74 | - public function getVersion(): ?string |
|
| 74 | + public function getVersion(): ? string |
|
| 75 | 75 | { |
| 76 | 76 | return $this->version; |
| 77 | 77 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @return null|string |
| 81 | 81 | */ |
| 82 | - public function getApiKey(): ?string |
|
| 82 | + public function getApiKey(): ? string |
|
| 83 | 83 | { |
| 84 | 84 | return $this->apiKey; |
| 85 | 85 | } |
@@ -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 | } |