@@ -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; |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | $body = $response->getBody(); |
93 | - while(!$body->eof()) { |
|
93 | + while (!$body->eof()) { |
|
94 | 94 | echo $body->read(1024); |
95 | 95 | } |
96 | 96 | } |
@@ -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 | } |
@@ -47,13 +47,13 @@ |
||
47 | 47 | { |
48 | 48 | $method = $this->mapEndpointMethod($request); |
49 | 49 | if (!method_exists($endpoint, $method)) { |
50 | - throw new MethodNotFoundException("The endpoint method " . $method . " was not found"); |
|
50 | + throw new MethodNotFoundException("The endpoint method ".$method." was not found"); |
|
51 | 51 | } |
52 | 52 | return call_user_func([$endpoint, $method], $request); |
53 | 53 | } |
54 | 54 | |
55 | 55 | protected function mapEndpointMethod(APIRequest $request): string |
56 | 56 | { |
57 | - return strtolower($request->getMethod()) . (!$request->getElement() ? 'All': ''); |
|
57 | + return strtolower($request->getMethod()).(!$request->getElement() ? 'All' : ''); |
|
58 | 58 | } |
59 | 59 | } |
@@ -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]; |