@@ -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 | |
@@ -29,7 +29,7 @@ discard block |
||
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 new LookupResponse($data[2], $data[3]); |
34 | 34 | } |
35 | 35 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param EndpointFactory $endpointFactory |
23 | 23 | */ |
24 | - public function __construct(EndpointFactory $endpointFactory){ |
|
24 | + public function __construct(EndpointFactory $endpointFactory) { |
|
25 | 25 | $this->endpointFactory = $endpointFactory; |
26 | 26 | } |
27 | 27 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @throws MethodNotFoundException |
44 | 44 | */ |
45 | 45 | protected function executeEndpoint(Endpoint $endpoint, Request $request): ResponseData { |
46 | - if(!method_exists($endpoint, $request->getMethod())){ |
|
46 | + if(!method_exists($endpoint, $request->getMethod())) { |
|
47 | 47 | throw new MethodNotFoundException("The endpoint method " . $request->getMethod() . " was not found"); |
48 | 48 | } |
49 | 49 | return call_user_func([$endpoint, $request->getMethod()], $request); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param ResponseFactory $responseFactory |
41 | 41 | * @param EndpointFactory $endpointFactory |
42 | 42 | */ |
43 | - public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory){ |
|
43 | + public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory) { |
|
44 | 44 | $this->accessControl = $accessControl; |
45 | 45 | $this->throttle = $throttle; |
46 | 46 | $this->responseFactory = $responseFactory; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param Request $request |
81 | 81 | * @throws InvalidAPIKeyException |
82 | 82 | */ |
83 | - protected function validateKey(Request $request){ |
|
84 | - if(!$this->accessControl->validateKey($request->getApiKey())){ |
|
83 | + protected function validateKey(Request $request) { |
|
84 | + if(!$this->accessControl->validateKey($request->getApiKey())) { |
|
85 | 85 | throw new InvalidAPIKeyException('Invalid API key'); |
86 | 86 | } |
87 | 87 | } |
@@ -42,26 +42,26 @@ |
||
42 | 42 | $response = $this->server->handleRequest($request); |
43 | 43 | header("Content-Type: " . $response->getMIMEType()); |
44 | 44 | echo $response->getAsString(); |
45 | - } catch(InvalidAPIKeyException $e){ |
|
45 | + } catch(InvalidAPIKeyException $e) { |
|
46 | 46 | header('400 Bad Request', true, 400); |
47 | - } catch(UnknownEndpointException $e){ |
|
47 | + } catch(UnknownEndpointException $e) { |
|
48 | 48 | header('404 Not Found', true, 404); |
49 | - } catch(NotAcceptableResponseTypeException $e){ |
|
49 | + } catch(NotAcceptableResponseTypeException $e) { |
|
50 | 50 | header('406 Not Acceptable', true, 406); |
51 | - } catch(AccessDeniedException $e){ |
|
51 | + } catch(AccessDeniedException $e) { |
|
52 | 52 | header('403 Access Denied', true, 403); |
53 | - } catch(ThrottleLimitExceededException $e){ |
|
53 | + } catch(ThrottleLimitExceededException $e) { |
|
54 | 54 | header('429 Too Many Requests', true, 429); |
55 | 55 | } catch (\Exception $e) { |
56 | 56 | header('500 Internal Server Error', true, 500); |
57 | 57 | } |
58 | - } catch(InvalidRequestURLException $e){ |
|
58 | + } catch(InvalidRequestURLException $e) { |
|
59 | 59 | header('400 Bad Request', true, 400); |
60 | - } catch(UnknownContentTypeException $e){ |
|
60 | + } catch(UnknownContentTypeException $e) { |
|
61 | 61 | header('400 Bad Request', true, 400); |
62 | - } catch(InvalidRequestDataException $e){ |
|
62 | + } catch(InvalidRequestDataException $e) { |
|
63 | 63 | header('400 Bad Request', true, 400); |
64 | - } catch(\Exception $e){ |
|
64 | + } catch(\Exception $e) { |
|
65 | 65 | header('500 Internal Server Error', true, 500); |
66 | 66 | } |
67 | 67 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function getEndpoint(string $name, string $version): Endpoint { |
25 | 25 | $className = $this->buildVersionedEndpointNamespace($version) . $name; |
26 | - if(!class_exists($className)){ |
|
26 | + if(!class_exists($className)) { |
|
27 | 27 | throw new UnknownEndpointException("Could not find $className"); |
28 | 28 | } |
29 | 29 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | class DoctrineEndpoint extends DefaultEndpoint { |
10 | 10 | protected $entityManager; |
11 | 11 | |
12 | - public function __construct(EntityManager $em){ |
|
12 | + public function __construct(EntityManager $em) { |
|
13 | 13 | $this->entityManager = $em; |
14 | 14 | } |
15 | 15 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param Configuration $config a config that has a list of valid keys in the stored $configKey |
23 | 23 | * @param string $configKey key to use when accessing the list of valid keys from the $config |
24 | 24 | */ |
25 | - public function __construct(Configuration $config, $configKey = 'keys'){ |
|
25 | + public function __construct(Configuration $config, $configKey = 'keys') { |
|
26 | 26 | $this->config = $config; |
27 | 27 | $this->configKey = $configKey; |
28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \LunixREST\Request\Request $request |
32 | 32 | * @return bool true if this key is valid |
33 | 33 | */ |
34 | - public function validateAccess(Request $request){ |
|
34 | + public function validateAccess(Request $request) { |
|
35 | 35 | return $this->validateKey($request->getApiKey()); |
36 | 36 | } |
37 | 37 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param $apiKey |
40 | 40 | * @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 |
41 | 41 | */ |
42 | - public function validateKey($apiKey){ |
|
42 | + public function validateKey($apiKey) { |
|
43 | 43 | return in_array($apiKey, $this->config->get($this->configKey)); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @param array $keys |
17 | 17 | */ |
18 | - public function __construct(Array $keys){ |
|
18 | + public function __construct(Array $keys) { |
|
19 | 19 | $this->keys = $keys; |
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 in the array passed to this object in it's construction |
33 | 33 | */ |
34 | - public function validateKey($apiKey){ |
|
34 | + public function validateKey($apiKey) { |
|
35 | 35 | return in_array($apiKey, $this->keys); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * @param AccessControl[] $accessControls array of access controls to use based on implmentation |
17 | 17 | */ |
18 | - public function __construct(array $accessControls){ |
|
18 | + public function __construct(array $accessControls) { |
|
19 | 19 | $this->accessControls = $accessControls; |
20 | 20 | } |
21 | 21 | } |
22 | 22 | \ No newline at end of file |