@@ -7,7 +7,7 @@ |
||
7 | 7 | class phonenumbers extends Endpoint { |
8 | 8 | |
9 | 9 | public function get(){ |
10 | - $geoPhone = new GeoPhone('data.csv'); |
|
11 | - return $geoPhone->lookupNumber($this->request->getInstance()); |
|
12 | - } |
|
10 | + $geoPhone = new GeoPhone('data.csv'); |
|
11 | + return $geoPhone->lookupNumber($this->request->getInstance()); |
|
12 | + } |
|
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class phonenumbers extends Endpoint { |
8 | 8 | |
9 | - public function get(){ |
|
9 | + public function get() { |
|
10 | 10 | $geoPhone = new GeoPhone('data.csv'); |
11 | 11 | return $geoPhone->lookupNumber($this->request->getInstance()); |
12 | 12 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param string $filename |
16 | 16 | */ |
17 | - public function __construct($filename = 'data.csv'){ |
|
17 | + public function __construct($filename = 'data.csv') { |
|
18 | 18 | $this->fileHandle = fopen($filename, 'r'); |
19 | 19 | } |
20 | 20 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * @return array an array with one value keyed with "location". The value is an array with two keys "city" and "state". |
24 | 24 | * City and state are empty when not found. |
25 | 25 | */ |
26 | - public function lookupNumber($phoneNumber){ |
|
26 | + public function lookupNumber($phoneNumber) { |
|
27 | 27 | $phoneNumber = preg_replace('/[^0-9]/s', '', $phoneNumber); |
28 | 28 | $areaCode = substr($phoneNumber, 0, 3); |
29 | 29 | $nextThree = substr($phoneNumber, 3, 3); |
30 | 30 | |
31 | 31 | while (($data = fgetcsv($this->fileHandle)) !== FALSE) { |
32 | - if($areaCode == $data[0] && $nextThree == $data[1]){ |
|
32 | + if ($areaCode == $data[0] && $nextThree == $data[1]) { |
|
33 | 33 | return ["location" => |
34 | 34 | [ |
35 | 35 | 'city' => $data[2], |
@@ -5,6 +5,6 @@ |
||
5 | 5 | |
6 | 6 | class helloworld extends Endpoint { |
7 | 7 | public function getAll(){ |
8 | - return ["helloworld" => "hello world"]; |
|
9 | - } |
|
8 | + return ["helloworld" => "hello world"]; |
|
9 | + } |
|
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -4,7 +4,7 @@ |
||
4 | 4 | use LunixREST\Endpoints\Endpoint; |
5 | 5 | |
6 | 6 | class helloworld extends Endpoint { |
7 | - public function getAll(){ |
|
7 | + public function getAll() { |
|
8 | 8 | return ["helloworld" => "hello world"]; |
9 | 9 | } |
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | header('404 Not Found', 404); |
22 | 22 | } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
23 | 23 | header('403 Access Denied', 403); |
24 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
24 | + } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | 25 | header('429 Too Many Requests', 429); |
26 | 26 | } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
27 | 27 | header('500 Internal Server Error', 500); |
@@ -9,27 +9,27 @@ |
||
9 | 9 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "HelloWorld"); |
10 | 10 | |
11 | 11 | try { |
12 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
12 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | 13 | |
14 | - try { |
|
15 | - echo $router->handle($request); |
|
16 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | - header('400 Bad Request', true, 400); |
|
18 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | - header('404 Not Found', true, 404); |
|
20 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | - header('404 Not Found', true, 404); |
|
22 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
23 | - header('403 Access Denied', true, 403); |
|
24 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | - header('429 Too Many Requests', true, 429); |
|
26 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
27 | - header('500 Internal Server Error', true, 500); |
|
28 | - } catch(Exception $e){ |
|
29 | - header('500 Internal Server Error', true, 500); |
|
30 | - } |
|
14 | + try { |
|
15 | + echo $router->handle($request); |
|
16 | + } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | + header('400 Bad Request', true, 400); |
|
18 | + } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | + header('404 Not Found', true, 404); |
|
20 | + } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | + header('404 Not Found', true, 404); |
|
22 | + } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
23 | + header('403 Access Denied', true, 403); |
|
24 | + } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | + header('429 Too Many Requests', true, 429); |
|
26 | + } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
27 | + header('500 Internal Server Error', true, 500); |
|
28 | + } catch(Exception $e){ |
|
29 | + header('500 Internal Server Error', true, 500); |
|
30 | + } |
|
31 | 31 | } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
32 | - header('400 Bad Request', true, 400); |
|
32 | + header('400 Bad Request', true, 400); |
|
33 | 33 | } catch(Exception $e){ |
34 | - header('500 Internal Server Error', true, 500); |
|
34 | + header('500 Internal Server Error', true, 500); |
|
35 | 35 | } |
@@ -9,27 +9,27 @@ |
||
9 | 9 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "HelloWorld"); |
10 | 10 | |
11 | 11 | try { |
12 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
12 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | 13 | |
14 | 14 | try { |
15 | 15 | echo $router->handle($request); |
16 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
16 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
17 | 17 | header('400 Bad Request', true, 400); |
18 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
18 | + } catch (\LunixREST\Exceptions\UnknownEndpointException $e) { |
|
19 | 19 | header('404 Not Found', true, 404); |
20 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
20 | + } catch (\LunixREST\Exceptions\UnknownResponseFormatException $e) { |
|
21 | 21 | header('404 Not Found', true, 404); |
22 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
22 | + } catch (\LunixREST\Exceptions\AccessDeniedException $e) { |
|
23 | 23 | header('403 Access Denied', true, 403); |
24 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
24 | + } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) { |
|
25 | 25 | header('429 Too Many Requests', true, 429); |
26 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
26 | + } catch (\LunixREST\Exceptions\InvalidResponseFormatException $e) { |
|
27 | 27 | header('500 Internal Server Error', true, 500); |
28 | - } catch(Exception $e){ |
|
28 | + } catch (Exception $e) { |
|
29 | 29 | header('500 Internal Server Error', true, 500); |
30 | 30 | } |
31 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
31 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
32 | 32 | header('400 Bad Request', true, 400); |
33 | -} catch(Exception $e){ |
|
33 | +} catch (Exception $e) { |
|
34 | 34 | header('500 Internal Server Error', true, 500); |
35 | 35 | } |
@@ -17,56 +17,56 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @param Request $request |
19 | 19 | */ |
20 | - public function __construct(Request $request){ |
|
20 | + public function __construct(Request $request) { |
|
21 | 21 | $this->request = $request; |
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @return array |
26 | 26 | */ |
27 | - public function get(){ |
|
27 | + public function get() { |
|
28 | 28 | $this->unsupportedMethod(); |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - public function getAll(){ |
|
34 | + public function getAll() { |
|
35 | 35 | $this->unsupportedMethod(); |
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function post(){ |
|
41 | + public function post() { |
|
42 | 42 | $this->unsupportedMethod(); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - public function postAll(){ |
|
48 | + public function postAll() { |
|
49 | 49 | $this->unsupportedMethod(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - public function put(){ |
|
55 | + public function put() { |
|
56 | 56 | $this->unsupportedMethod(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function putAll(){ |
|
62 | + public function putAll() { |
|
63 | 63 | $this->unsupportedMethod(); |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function options(){ |
|
69 | + public function options() { |
|
70 | 70 | $this->unsupportedMethod(); |
71 | 71 | } |
72 | 72 | |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function optionsAll(){ |
|
77 | + public function optionsAll() { |
|
78 | 78 | $this->unsupportedMethod(); |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function delete(){ |
|
84 | + public function delete() { |
|
85 | 85 | $this->unsupportedMethod(); |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - public function deleteAll(){ |
|
91 | + public function deleteAll() { |
|
92 | 92 | $this->unsupportedMethod(); |
93 | 93 | } |
94 | 94 | |
95 | - private function unsupportedMethod(){ |
|
95 | + private function unsupportedMethod() { |
|
96 | 96 | throw new UnknownEndpointException('Method not supported'); |
97 | 97 | } |
98 | 98 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $extension |
58 | 58 | * @param string $instance |
59 | 59 | */ |
60 | - public function __construct($method, array $headers, array $data, $ip, $version, $apiKey, $endpoint, $extension, $instance = null){ |
|
60 | + public function __construct($method, array $headers, array $data, $ip, $version, $apiKey, $endpoint, $extension, $instance = null) { |
|
61 | 61 | $this->method = strtolower($method); |
62 | 62 | $this->headers = $headers; |
63 | 63 | $this->data = $data; |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @return Request |
151 | 151 | * @throws InvalidRequestFormatException |
152 | 152 | */ |
153 | - public static function createFromURL($method, array $headers, array $data, $ip, $url){ |
|
153 | + public static function createFromURL($method, array $headers, array $data, $ip, $url) { |
|
154 | 154 | $splitURL = explode('/', trim($url, '/')); |
155 | - if(count($splitURL) < 3){ |
|
155 | + if (count($splitURL) < 3) { |
|
156 | 156 | throw new InvalidRequestFormatException(); |
157 | 157 | } |
158 | 158 | //Find endpoint |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $instance = null; |
167 | 167 | |
168 | - if(count($splitURL) == 4){ |
|
168 | + if (count($splitURL) == 4) { |
|
169 | 169 | $instance = implode('.', $splitExtension); |
170 | 170 | } else { |
171 | 171 | $endpoint = implode('.', $splitExtension); |
@@ -10,29 +10,29 @@ |
||
10 | 10 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "GeoPhone"); |
11 | 11 | |
12 | 12 | try { |
13 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
14 | 14 | |
15 | - try { |
|
16 | - echo $router->handle($request); |
|
17 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
18 | - header('400 Bad Request', true, 400); |
|
19 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
20 | - header('404 Not Found', true, 404); |
|
21 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
22 | - header('404 Not Found', true, 404); |
|
23 | - } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
24 | - header('404 Not Found', true, 404); |
|
25 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
26 | - header('403 Access Denied', true, 403); |
|
27 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
28 | - header('429 Too Many Requests', true, 429); |
|
29 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
30 | - header('500 Internal Server Error', true, 500); |
|
31 | - } catch(Exception $e){ |
|
32 | - header('500 Internal Server Error', true, 500); |
|
33 | - } |
|
15 | + try { |
|
16 | + echo $router->handle($request); |
|
17 | + } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
18 | + header('400 Bad Request', true, 400); |
|
19 | + } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
20 | + header('404 Not Found', true, 404); |
|
21 | + } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
22 | + header('404 Not Found', true, 404); |
|
23 | + } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
24 | + header('404 Not Found', true, 404); |
|
25 | + } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
26 | + header('403 Access Denied', true, 403); |
|
27 | + } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
28 | + header('429 Too Many Requests', true, 429); |
|
29 | + } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
30 | + header('500 Internal Server Error', true, 500); |
|
31 | + } catch(Exception $e){ |
|
32 | + header('500 Internal Server Error', true, 500); |
|
33 | + } |
|
34 | 34 | } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
35 | - header('400 Bad Request', 400); |
|
35 | + header('400 Bad Request', 400); |
|
36 | 36 | } catch(Exception $e){ |
37 | - header('500 Internal Server Error', true, 500); |
|
37 | + header('500 Internal Server Error', true, 500); |
|
38 | 38 | } |
@@ -10,29 +10,29 @@ |
||
10 | 10 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $formatsConfig, "GeoPhone"); |
11 | 11 | |
12 | 12 | try { |
13 | - $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
13 | + $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']); |
|
14 | 14 | |
15 | 15 | try { |
16 | 16 | echo $router->handle($request); |
17 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
18 | 18 | header('400 Bad Request', true, 400); |
19 | - } catch(\LunixREST\Exceptions\UnknownEndpointException $e){ |
|
19 | + } catch (\LunixREST\Exceptions\UnknownEndpointException $e) { |
|
20 | 20 | header('404 Not Found', true, 404); |
21 | - } catch(\LunixREST\Exceptions\UnknownResponseFormatException $e){ |
|
21 | + } catch (\LunixREST\Exceptions\UnknownResponseFormatException $e) { |
|
22 | 22 | header('404 Not Found', true, 404); |
23 | - } catch(\LunixREST\Exceptions\InstanceNotFoundException $e){ |
|
23 | + } catch (\LunixREST\Exceptions\InstanceNotFoundException $e) { |
|
24 | 24 | header('404 Not Found', true, 404); |
25 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
25 | + } catch (\LunixREST\Exceptions\AccessDeniedException $e) { |
|
26 | 26 | header('403 Access Denied', true, 403); |
27 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
27 | + } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) { |
|
28 | 28 | header('429 Too Many Requests', true, 429); |
29 | - } catch(\LunixREST\Exceptions\InvalidResponseFormatException $e){ |
|
29 | + } catch (\LunixREST\Exceptions\InvalidResponseFormatException $e) { |
|
30 | 30 | header('500 Internal Server Error', true, 500); |
31 | - } catch(Exception $e){ |
|
31 | + } catch (Exception $e) { |
|
32 | 32 | header('500 Internal Server Error', true, 500); |
33 | 33 | } |
34 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
34 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
35 | 35 | header('400 Bad Request', 400); |
36 | -} catch(Exception $e){ |
|
36 | +} catch (Exception $e) { |
|
37 | 37 | header('500 Internal Server Error', true, 500); |
38 | 38 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param Configuration $formatsConfig |
46 | 46 | * @param string $endpointNamespace |
47 | 47 | */ |
48 | - public function __construct(AccessControl $accessControl, Throttle $throttle, Configuration $formatsConfig, $endpointNamespace = ''){ |
|
48 | + public function __construct(AccessControl $accessControl, Throttle $throttle, Configuration $formatsConfig, $endpointNamespace = '') { |
|
49 | 49 | $this->accessControl = $accessControl; |
50 | 50 | $this->throttle = $throttle; |
51 | 51 | $this->formatsConfig = $formatsConfig; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @throws UnknownEndpointException |
63 | 63 | * @throws UnknownResponseFormatException |
64 | 64 | */ |
65 | - public function handle(Request $request){ |
|
65 | + public function handle(Request $request) { |
|
66 | 66 | $this->validateKey($request); |
67 | 67 | |
68 | 68 | $this->validateExtension($request); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param Request $request |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - private function endpointClass(Request $request){ |
|
92 | + private function endpointClass(Request $request) { |
|
93 | 93 | return '\\' . $this->endpointNamespace . '\Endpoints\v' . str_replace('.', '_', $request->getVersion()) . '\\' . $request->getEndpoint(); |
94 | 94 | } |
95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param Request $request |
98 | 98 | * @return string |
99 | 99 | */ |
100 | - private function responseClass(Request $request){ |
|
100 | + private function responseClass(Request $request) { |
|
101 | 101 | return '\\LunixREST\\Response\\' . strtoupper($request->getExtension()) . "Response"; |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param Request $request |
106 | 106 | * @throws InvalidAPIKeyException |
107 | 107 | */ |
108 | - private function validateKey(Request $request){ |
|
109 | - if(!$this->accessControl->validateKey($request->getApiKey())){ |
|
108 | + private function validateKey(Request $request) { |
|
109 | + if (!$this->accessControl->validateKey($request->getApiKey())) { |
|
110 | 110 | throw new InvalidAPIKeyException('Invalid API key'); |
111 | 111 | } |
112 | 112 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | private function validateExtension(Request $request) |
120 | 120 | { |
121 | 121 | $formats = $this->formatsConfig->get('formats'); |
122 | - if(!($formats && in_array($request->getExtension(), $formats))){ |
|
123 | - throw new UnknownResponseFormatException('Unknown response format: ' .$request->getExtension()); |
|
122 | + if (!($formats && in_array($request->getExtension(), $formats))) { |
|
123 | + throw new UnknownResponseFormatException('Unknown response format: ' . $request->getExtension()); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @param $fullEndpoint |
129 | 129 | * @throws UnknownEndpointException |
130 | 130 | */ |
131 | - private function validateEndpoint($fullEndpoint){ |
|
131 | + private function validateEndpoint($fullEndpoint) { |
|
132 | 132 | $endpointReflection = new \ReflectionClass($fullEndpoint); |
133 | - if(!class_exists($fullEndpoint) || !$endpointReflection->isSubclassOf('\LunixREST\Endpoints\Endpoint')){ |
|
133 | + if (!class_exists($fullEndpoint) || !$endpointReflection->isSubclassOf('\LunixREST\Endpoints\Endpoint')) { |
|
134 | 134 | throw new UnknownEndpointException("unknown endpoint: " . $fullEndpoint); |
135 | 135 | } |
136 | 136 | } |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param Request $request |
140 | 140 | * @throws ThrottleLimitExceededException |
141 | 141 | */ |
142 | - private function throttle(Request $request){ |
|
143 | - if($this->throttle->throttle($request)){ |
|
142 | + private function throttle(Request $request) { |
|
143 | + if ($this->throttle->throttle($request)) { |
|
144 | 144 | throw new ThrottleLimitExceededException('Request limit exceeded'); |
145 | 145 | } |
146 | 146 | } |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param Request $request |
150 | 150 | * @throws AccessDeniedException |
151 | 151 | */ |
152 | - private function validateAccess(Request $request){ |
|
153 | - if(!$this->accessControl->validateAccess($request)){ |
|
152 | + private function validateAccess(Request $request) { |
|
153 | + if (!$this->accessControl->validateAccess($request)) { |
|
154 | 154 | throw new AccessDeniedException("API key does not have the required permissions to access requested resource"); |
155 | 155 | } |
156 | 156 | } |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | * @param $responseData |
160 | 160 | * @throws InvalidResponseFormatException |
161 | 161 | */ |
162 | - private function validateResponse($responseData){ |
|
163 | - if(!is_array($responseData)){ |
|
162 | + private function validateResponse($responseData) { |
|
163 | + if (!is_array($responseData)) { |
|
164 | 164 | throw new InvalidResponseFormatException('Method output MUST be an array'); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - private function executeEndpoint($fullEndpoint, Request $request){ |
|
168 | + private function executeEndpoint($fullEndpoint, Request $request) { |
|
169 | 169 | $endPoint = new $fullEndpoint($request); |
170 | 170 | return call_user_func([$endPoint, $request->getMethod()]); |
171 | 171 | } |