@@ -11,7 +11,7 @@ |
||
11 | 11 | * @throws NotAcceptableResponseTypeException |
12 | 12 | */ |
13 | 13 | public function getResponse(ResponseData $data, array $acceptedMIMETypes): Response { |
14 | - if(empty($acceptedMIMETypes)){ |
|
14 | + if(empty($acceptedMIMETypes)) { |
|
15 | 15 | $acceptedMIMETypes = $this->getSupportedMIMETypes(); |
16 | 16 | } |
17 | 17 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param string $filename |
23 | 23 | * @param string $nameSpace |
24 | 24 | */ |
25 | - public function __construct($filename, $nameSpace = null){ |
|
25 | + public function __construct($filename, $nameSpace = null) { |
|
26 | 26 | $this->filename = $filename; |
27 | 27 | $this->nameSpace = $nameSpace; |
28 | 28 | } |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * @throws INIKeyNotFoundException |
34 | 34 | * @throws INIParseException |
35 | 35 | */ |
36 | - public function get($key){ |
|
36 | + public function get($key) { |
|
37 | 37 | $config = parse_ini_file($this->filename, (bool)$this->nameSpace); |
38 | 38 | |
39 | - if($config === false){ |
|
39 | + if($config === false) { |
|
40 | 40 | throw new INIParseException('Could not parse: ' . $this->filename, true); |
41 | 41 | } |
42 | 42 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @param $key |
56 | 56 | */ |
57 | - public function set($key){ |
|
57 | + public function set($key) { |
|
58 | 58 | //TODO write this |
59 | 59 | } |
60 | 60 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function parse(string $url): ParsedURL { |
30 | 30 | $splitURL = explode('/', trim($url, '/')); |
31 | - if(count($splitURL) < 3){ |
|
31 | + if(count($splitURL) < 3) { |
|
32 | 32 | throw new InvalidRequestURLException(); |
33 | 33 | } |
34 | 34 | //Find endpoint |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $instance = null; |
43 | 43 | |
44 | - if(count($splitURL) == 4){ |
|
44 | + if(count($splitURL) == 4) { |
|
45 | 45 | $instance = implode('.', $splitExtension); |
46 | 46 | } else { |
47 | 47 | $endpoint = implode('.', $splitExtension); |
@@ -64,7 +64,7 @@ |
||
64 | 64 | * @internal param string $extension |
65 | 65 | */ |
66 | 66 | |
67 | - public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null){ |
|
67 | + public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null) { |
|
68 | 68 | $this->method = strtolower($method); |
69 | 69 | $this->headers = $headers; |
70 | 70 | $this->body = $body; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param \LunixREST\Request\Request $request |
12 | 12 | * @return bool |
13 | 13 | */ |
14 | - public function validateAccess(Request $request){ |
|
14 | + public function validateAccess(Request $request) { |
|
15 | 15 | return true; |
16 | 16 | } |
17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param $apiKey |
20 | 20 | * @return bool |
21 | 21 | */ |
22 | - public function validateKey($apiKey){ |
|
22 | + public function validateKey($apiKey) { |
|
23 | 23 | return true; |
24 | 24 | } |
25 | 25 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @param string $key |
17 | 17 | */ |
18 | - public function __construct($key){ |
|
18 | + public function __construct($key) { |
|
19 | 19 | $this->key = $key; |
20 | 20 | } |
21 | 21 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param \LunixREST\Request\Request $request |
24 | 24 | * @return bool true if key is valid |
25 | 25 | */ |
26 | - public function validateAccess(Request $request){ |
|
26 | + public function validateAccess(Request $request) { |
|
27 | 27 | return $this->validateKey($request->getApiKey()); |
28 | 28 | } |
29 | 29 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param $apiKey |
32 | 32 | * @return bool true if key is the key specified in the constructor |
33 | 33 | */ |
34 | - public function validateKey($apiKey){ |
|
34 | + public function validateKey($apiKey) { |
|
35 | 35 | return $apiKey === $this->key; |
36 | 36 | } |
37 | 37 | } |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | //TODO: follow RFC2616 order |
26 | 26 | $acceptedMIMETypes = []; |
27 | 27 | foreach($headers as $key => $value) { |
28 | - if(strtolower($key) == 'http-accept'){ |
|
28 | + if(strtolower($key) == 'http-accept') { |
|
29 | 29 | $values = explode(',', $value); |
30 | 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){ |
|
42 | + protected function findAPIKey(array $headers) { |
|
43 | 43 | foreach($headers as $key => $value) { |
44 | - if(strtolower($key) == strtolower($this->apiKeyHeaderKey)){ |
|
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){ |
|
51 | + protected function getContentType(array $headers) { |
|
52 | 52 | foreach($headers as $key => $value) { |
53 | - if(strtolower($key) == 'content-type'){ |
|
53 | + if(strtolower($key) == 'content-type') { |
|
54 | 54 | return $value; |
55 | 55 | } |
56 | 56 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | //Borrowed from http://stackoverflow.com/a/1147952 |
15 | 15 | public function getAll(): array { |
16 | - if($this->cache){ |
|
16 | + if($this->cache) { |
|
17 | 17 | return $this->cache; |
18 | 18 | } |
19 | 19 |