@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param Configuration $config a config that has a list of valid keys in the stored $configKey |
24 | 24 | * @param string $configKey key to use when accessing the list of valid keys from the $config |
25 | 25 | */ |
26 | - public function __construct(Configuration $config, $configKey = 'keys'){ |
|
26 | + public function __construct(Configuration $config, $configKey = 'keys') { |
|
27 | 27 | $this->config = $config; |
28 | 28 | $this->configKey = $configKey; |
29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param \LunixREST\Request\Request $request |
33 | 33 | * @return bool true if this key is valid |
34 | 34 | */ |
35 | - public function validateAccess(Request $request){ |
|
35 | + public function validateAccess(Request $request) { |
|
36 | 36 | return $this->validateKey($request->getApiKey()); |
37 | 37 | } |
38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param $apiKey |
41 | 41 | * @return bool true if the key is found inside of the array returned by the config when $config->get is called with the key from the constructor |
42 | 42 | */ |
43 | - public function validateKey($apiKey){ |
|
43 | + public function validateKey($apiKey) { |
|
44 | 44 | return in_array($apiKey, $this->config->get($this->configKey)); |
45 | 45 | } |
46 | 46 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | protected function findAcceptableMIMETypes(array $headers): array{ |
25 | 25 | //TODO: follow RFC2616 order |
26 | 26 | $acceptedMIMETypes = []; |
27 | - foreach($headers as $key => $value) { |
|
28 | - if(strtolower($key) == 'http-accept'){ |
|
27 | + foreach ($headers as $key => $value) { |
|
28 | + if (strtolower($key) == 'http-accept') { |
|
29 | 29 | $values = explode(',', $value); |
30 | - foreach($values as $acceptedType) { |
|
30 | + foreach ($values as $acceptedType) { |
|
31 | 31 | $typeParts = explode(';', $acceptedType); |
32 | - if(count($typeParts) > 0 ){ |
|
32 | + if (count($typeParts) > 0) { |
|
33 | 33 | $acceptedMIMETypes[] = trim($typeParts[0]); |
34 | 34 | } |
35 | 35 | } |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | return $acceptedMIMETypes; |
40 | 40 | } |
41 | 41 | |
42 | - protected function findAPIKey(array $headers){ |
|
43 | - foreach($headers as $key => $value) { |
|
44 | - if(strtolower($key) == strtolower($this->apiKeyHeaderKey)){ |
|
42 | + protected function findAPIKey(array $headers) { |
|
43 | + foreach ($headers as $key => $value) { |
|
44 | + if (strtolower($key) == strtolower($this->apiKeyHeaderKey)) { |
|
45 | 45 | return $value; |
46 | 46 | } |
47 | 47 | } |
48 | 48 | return null; |
49 | 49 | } |
50 | 50 | |
51 | - protected function getContentType(array $headers){ |
|
52 | - foreach($headers as $key => $value) { |
|
53 | - if(strtolower($key) == 'content-type'){ |
|
51 | + protected function getContentType(array $headers) { |
|
52 | + foreach ($headers as $key => $value) { |
|
53 | + if (strtolower($key) == 'content-type') { |
|
54 | 54 | return $value; |
55 | 55 | } |
56 | 56 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param BodyParser[] $mappings keyed by content type |
19 | 19 | */ |
20 | 20 | public function __construct($mappings = []) { |
21 | - foreach($mappings as $contentType => $bodyParser) { |
|
21 | + foreach ($mappings as $contentType => $bodyParser) { |
|
22 | 22 | $this->add($contentType, $bodyParser); |
23 | 23 | } |
24 | 24 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @throws UnknownContentTypeException |
39 | 39 | */ |
40 | 40 | public function create(string $contentType): BodyParser { |
41 | - if(isset($this->contentTypeToParserMap[strtolower($contentType)])){ |
|
41 | + if (isset($this->contentTypeToParserMap[strtolower($contentType)])) { |
|
42 | 42 | return $this->contentTypeToParserMap[strtolower($contentType)]; |
43 | 43 | } |
44 | 44 |