@@ -11,26 +11,26 @@ |
||
11 | 11 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory); |
12 | 12 | |
13 | 13 | try { |
14 | - $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']); |
|
14 | + $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']); |
|
15 | 15 | |
16 | 16 | try { |
17 | 17 | $response = $router->route($request); |
18 | 18 | echo $response->getAsString(); |
19 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
19 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
20 | 20 | header('400 Bad Request', true, 400); |
21 | - } catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){ |
|
21 | + } catch (\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e) { |
|
22 | 22 | header('404 Not Found', true, 404); |
23 | - } catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){ |
|
23 | + } catch (\LunixREST\Response\Exceptions\UnknownResponseTypeException $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(Exception $e){ |
|
29 | + } catch (Exception $e) { |
|
30 | 30 | header('500 Internal Server Error', true, 500); |
31 | 31 | } |
32 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
32 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
33 | 33 | header('400 Bad Request', true, 400); |
34 | -} catch(Exception $e){ |
|
34 | +} catch (Exception $e) { |
|
35 | 35 | header('500 Internal Server Error', true, 500); |
36 | 36 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @throws UnknownEndpointException |
21 | 21 | */ |
22 | 22 | public function getEndpoint(string $name, string $version): Endpoint { |
23 | - $className = $this->buildVersionedEndpointNamespace($version) . $name; |
|
23 | + $className = $this->buildVersionedEndpointNamespace($version).$name; |
|
24 | 24 | return new $className($this->entityManager); |
25 | 25 | } |
26 | 26 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @throws UnknownEndpointException |
23 | 23 | */ |
24 | 24 | public function getEndpoint(string $name, string $version): Endpoint { |
25 | - $className = $this->buildVersionedEndpointNamespace($version) . $name; |
|
25 | + $className = $this->buildVersionedEndpointNamespace($version).$name; |
|
26 | 26 | return new $className(); |
27 | 27 | } |
28 | 28 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $classesInNamespace = []; |
36 | 36 | |
37 | 37 | $namespace = $this->buildVersionedEndpointNamespace($version); |
38 | - foreach(get_declared_classes() as $name) { |
|
38 | + foreach (get_declared_classes() as $name) { |
|
39 | 39 | if (strpos($name, $namespace) === 0) { |
40 | 40 | $classesInNamespace[] = $name; |
41 | 41 | } |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function buildVersionedEndpointNamespace(string $version): string { |
48 | - return $this->endpointNamespace . '\v' . str_replace('.', '_', $version) . '\\'; |
|
48 | + return $this->endpointNamespace.'\v'.str_replace('.', '_', $version).'\\'; |
|
49 | 49 | } |
50 | 50 | } |
@@ -9,26 +9,26 @@ |
||
9 | 9 | $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory); |
10 | 10 | |
11 | 11 | try { |
12 | - $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']); |
|
12 | + $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 | 13 | |
14 | 14 | try { |
15 | 15 | $response = $router->route($request); |
16 | 16 | echo $response->getAsString(); |
17 | - } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){ |
|
17 | + } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) { |
|
18 | 18 | header('400 Bad Request', true, 400); |
19 | - } catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){ |
|
19 | + } catch (\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e) { |
|
20 | 20 | header('404 Not Found', true, 404); |
21 | - } catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){ |
|
21 | + } catch (\LunixREST\Response\Exceptions\UnknownResponseTypeException $e) { |
|
22 | 22 | header('404 Not Found', true, 404); |
23 | - } catch(\LunixREST\Exceptions\AccessDeniedException $e){ |
|
23 | + } catch (\LunixREST\Exceptions\AccessDeniedException $e) { |
|
24 | 24 | header('403 Access Denied', true, 403); |
25 | - } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){ |
|
25 | + } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) { |
|
26 | 26 | header('429 Too Many Requests', true, 429); |
27 | - } catch(Exception $e){ |
|
27 | + } catch (Exception $e) { |
|
28 | 28 | header('500 Internal Server Error', true, 500); |
29 | 29 | } |
30 | -} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){ |
|
30 | +} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) { |
|
31 | 31 | header('400 Bad Request', 400); |
32 | -} catch(Exception $e){ |
|
32 | +} catch (Exception $e) { |
|
33 | 33 | header('500 Internal Server Error', true, 500); |
34 | 34 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * @throws UnknownEndpointException |
22 | 22 | */ |
23 | 23 | public function getEndpoint(string $name, string $version): Endpoint { |
24 | - switch($version) { |
|
24 | + switch ($version) { |
|
25 | 25 | case "1": |
26 | 26 | switch (strtolower($name)) { |
27 | 27 | case "phonenumbers": |
@@ -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 | } |