@@ -9,15 +9,13 @@ discard block |
||
9 | 9 | * Class Endpoint |
10 | 10 | * @package LunixREST\Endpoints |
11 | 11 | */ |
12 | -class DefaultEndpoint implements Endpoint |
|
13 | -{ |
|
12 | +class DefaultEndpoint implements Endpoint { |
|
14 | 13 | /** |
15 | 14 | * @param APIRequest $request |
16 | 15 | * @return null|array|object |
17 | 16 | * @throws UnsupportedMethodException |
18 | 17 | */ |
19 | - public function get(APIRequest $request) |
|
20 | - { |
|
18 | + public function get(APIRequest $request) { |
|
21 | 19 | throw new UnsupportedMethodException('Method not supported'); |
22 | 20 | } |
23 | 21 | |
@@ -26,8 +24,7 @@ discard block |
||
26 | 24 | * @return null|array|object |
27 | 25 | * @throws UnsupportedMethodException |
28 | 26 | */ |
29 | - public function getAll(APIRequest $request) |
|
30 | - { |
|
27 | + public function getAll(APIRequest $request) { |
|
31 | 28 | throw new UnsupportedMethodException('Method not supported'); |
32 | 29 | } |
33 | 30 | |
@@ -36,8 +33,7 @@ discard block |
||
36 | 33 | * @return null|array|object |
37 | 34 | * @throws UnsupportedMethodException |
38 | 35 | */ |
39 | - public function post(APIRequest $request) |
|
40 | - { |
|
36 | + public function post(APIRequest $request) { |
|
41 | 37 | throw new UnsupportedMethodException('Method not supported'); |
42 | 38 | } |
43 | 39 | |
@@ -46,8 +42,7 @@ discard block |
||
46 | 42 | * @return null|array|object |
47 | 43 | * @throws UnsupportedMethodException |
48 | 44 | */ |
49 | - public function postAll(APIRequest $request) |
|
50 | - { |
|
45 | + public function postAll(APIRequest $request) { |
|
51 | 46 | throw new UnsupportedMethodException('Method not supported'); |
52 | 47 | } |
53 | 48 | |
@@ -56,8 +51,7 @@ discard block |
||
56 | 51 | * @return null|array|object |
57 | 52 | * @throws UnsupportedMethodException |
58 | 53 | */ |
59 | - public function put(APIRequest $request) |
|
60 | - { |
|
54 | + public function put(APIRequest $request) { |
|
61 | 55 | throw new UnsupportedMethodException('Method not supported'); |
62 | 56 | } |
63 | 57 | |
@@ -66,8 +60,7 @@ discard block |
||
66 | 60 | * @return null|array|object |
67 | 61 | * @throws UnsupportedMethodException |
68 | 62 | */ |
69 | - public function putAll(APIRequest $request) |
|
70 | - { |
|
63 | + public function putAll(APIRequest $request) { |
|
71 | 64 | throw new UnsupportedMethodException('Method not supported'); |
72 | 65 | } |
73 | 66 | |
@@ -76,8 +69,7 @@ discard block |
||
76 | 69 | * @return null|array|object |
77 | 70 | * @throws UnsupportedMethodException |
78 | 71 | */ |
79 | - public function options(APIRequest $request) |
|
80 | - { |
|
72 | + public function options(APIRequest $request) { |
|
81 | 73 | throw new UnsupportedMethodException('Method not supported'); |
82 | 74 | } |
83 | 75 | |
@@ -86,8 +78,7 @@ discard block |
||
86 | 78 | * @return null|array|object |
87 | 79 | * @throws UnsupportedMethodException |
88 | 80 | */ |
89 | - public function optionsAll(APIRequest $request) |
|
90 | - { |
|
81 | + public function optionsAll(APIRequest $request) { |
|
91 | 82 | throw new UnsupportedMethodException('Method not supported'); |
92 | 83 | } |
93 | 84 | |
@@ -96,8 +87,7 @@ discard block |
||
96 | 87 | * @return null|array|object |
97 | 88 | * @throws UnsupportedMethodException |
98 | 89 | */ |
99 | - public function delete(APIRequest $request) |
|
100 | - { |
|
90 | + public function delete(APIRequest $request) { |
|
101 | 91 | throw new UnsupportedMethodException('Method not supported'); |
102 | 92 | } |
103 | 93 | |
@@ -106,8 +96,7 @@ discard block |
||
106 | 96 | * @return null|array|object |
107 | 97 | * @throws UnsupportedMethodException |
108 | 98 | */ |
109 | - public function deleteAll(APIRequest $request) |
|
110 | - { |
|
99 | + public function deleteAll(APIRequest $request) { |
|
111 | 100 | throw new UnsupportedMethodException('Method not supported'); |
112 | 101 | } |
113 | 102 | } |
@@ -28,8 +28,7 @@ |
||
28 | 28 | * @param URLParser $URLParser |
29 | 29 | * @param HeaderParser $headerParser |
30 | 30 | */ |
31 | - public function __construct(URLParser $URLParser, HeaderParser $headerParser) |
|
32 | - { |
|
31 | + public function __construct(URLParser $URLParser, HeaderParser $headerParser) { |
|
33 | 32 | $this->URLParser = $URLParser; |
34 | 33 | $this->headerParser = $headerParser; |
35 | 34 | } |
@@ -48,12 +48,12 @@ |
||
48 | 48 | $parsedHeaders = $this->headerParser->parse($serverRequest->getHeaders()); |
49 | 49 | |
50 | 50 | $urlQueryData = []; |
51 | - if($urlQueryString = $parsedURL->getQueryString()) { |
|
51 | + if ($urlQueryString = $parsedURL->getQueryString()) { |
|
52 | 52 | parse_str($urlQueryString, $urlQueryData); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $apiKey = $parsedURL->getAPIKey(); |
56 | - if($apiKey === null) { |
|
56 | + if ($apiKey === null) { |
|
57 | 57 | $apiKey = $parsedHeaders->getAPIKey(); |
58 | 58 | } |
59 | 59 |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * Class GenericRouter |
11 | 11 | * @package LunixREST\Server |
12 | 12 | */ |
13 | -class GenericRouter implements Router |
|
14 | -{ |
|
13 | +class GenericRouter implements Router { |
|
15 | 14 | /** |
16 | 15 | * @var EndpointFactory |
17 | 16 | */ |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * DefaultRouter constructor. |
22 | 21 | * @param EndpointFactory $endpointFactory |
23 | 22 | */ |
24 | - public function __construct(EndpointFactory $endpointFactory) |
|
25 | - { |
|
23 | + public function __construct(EndpointFactory $endpointFactory) { |
|
26 | 24 | $this->endpointFactory = $endpointFactory; |
27 | 25 | } |
28 | 26 | |
@@ -31,8 +29,7 @@ discard block |
||
31 | 29 | * @return null|object|array |
32 | 30 | * @throws MethodNotFoundException |
33 | 31 | */ |
34 | - public function route(APIRequest $request) |
|
35 | - { |
|
32 | + public function route(APIRequest $request) { |
|
36 | 33 | $endpoint = $this->endpointFactory->getEndpoint($request->getEndpoint(), $request->getVersion()); |
37 | 34 | return $this->executeEndpoint($endpoint, $request); |
38 | 35 | } |
@@ -43,8 +40,7 @@ discard block |
||
43 | 40 | * @return null|object|array |
44 | 41 | * @throws MethodNotFoundException |
45 | 42 | */ |
46 | - protected function executeEndpoint(Endpoint $endpoint, APIRequest $request) |
|
47 | - { |
|
43 | + protected function executeEndpoint(Endpoint $endpoint, APIRequest $request) { |
|
48 | 44 | $method = $this->mapEndpointMethod($request); |
49 | 45 | if (!method_exists($endpoint, $method)) { |
50 | 46 | throw new MethodNotFoundException("The endpoint method " . $method . " was not found"); |
@@ -47,13 +47,13 @@ |
||
47 | 47 | { |
48 | 48 | $method = $this->mapEndpointMethod($request); |
49 | 49 | if (!method_exists($endpoint, $method)) { |
50 | - throw new MethodNotFoundException("The endpoint method " . $method . " was not found"); |
|
50 | + throw new MethodNotFoundException("The endpoint method ".$method." was not found"); |
|
51 | 51 | } |
52 | 52 | return call_user_func([$endpoint, $method], $request); |
53 | 53 | } |
54 | 54 | |
55 | 55 | protected function mapEndpointMethod(APIRequest $request): string |
56 | 56 | { |
57 | - return strtolower($request->getMethod()) . (!$request->getElement() ? 'All': ''); |
|
57 | + return strtolower($request->getMethod()).(!$request->getElement() ? 'All' : ''); |
|
58 | 58 | } |
59 | 59 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Psr\Log\LoggerAwareTrait; |
5 | 5 | |
6 | -abstract class LoggingEndpoint implements Endpoint |
|
7 | -{ |
|
6 | +abstract class LoggingEndpoint implements Endpoint { |
|
8 | 7 | use LoggerAwareTrait; |
9 | 8 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * Class LoggingEndpointFactory |
8 | 8 | * @package LunixREST\Endpoint |
9 | 9 | */ |
10 | -abstract class LoggingEndpointFactory implements EndpointFactory |
|
11 | -{ |
|
10 | +abstract class LoggingEndpointFactory implements EndpointFactory { |
|
12 | 11 | /** |
13 | 12 | * @var LoggerInterface |
14 | 13 | */ |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | * LoggingEndpointFactory constructor. |
19 | 18 | * @param LoggerInterface $logger |
20 | 19 | */ |
21 | - public function __construct(LoggerInterface $logger) |
|
22 | - { |
|
20 | + public function __construct(LoggerInterface $logger) { |
|
23 | 21 | $this->logger = $logger; |
24 | 22 | } |
25 | 23 |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | * Class CachingEndpointFactory |
9 | 9 | * @package LunixREST\Endpoint |
10 | 10 | */ |
11 | -abstract class CachingEndpointFactory extends LoggingEndpointFactory |
|
12 | -{ |
|
11 | +abstract class CachingEndpointFactory extends LoggingEndpointFactory { |
|
13 | 12 | /** |
14 | 13 | * @var CacheItemPoolInterface |
15 | 14 | */ |
@@ -20,8 +19,7 @@ discard block |
||
20 | 19 | * @param CacheItemPoolInterface $cachePool |
21 | 20 | * @param LoggerInterface $logger |
22 | 21 | */ |
23 | - public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger) |
|
24 | - { |
|
22 | + public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger) { |
|
25 | 23 | $this->cachePool = $cachePool; |
26 | 24 | parent::__construct($logger); |
27 | 25 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * Class CachingEndpoint |
8 | 8 | * @package LunixREST\Endpoint |
9 | 9 | */ |
10 | -abstract class CachingEndpoint extends LoggingEndpoint |
|
11 | -{ |
|
10 | +abstract class CachingEndpoint extends LoggingEndpoint { |
|
12 | 11 | /** |
13 | 12 | * @var CacheItemPoolInterface |
14 | 13 | */ |
@@ -17,8 +16,7 @@ discard block |
||
17 | 16 | /** |
18 | 17 | * @param CacheItemPoolInterface $cacheItemPool |
19 | 18 | */ |
20 | - public function setCachePool(CacheItemPoolInterface $cacheItemPool) |
|
21 | - { |
|
19 | + public function setCachePool(CacheItemPoolInterface $cacheItemPool) { |
|
22 | 20 | $this->cachePool = $cacheItemPool; |
23 | 21 | } |
24 | 22 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | $this->config = parse_ini_file($filename, true); |
25 | 25 | |
26 | 26 | if ($this->config === false) { |
27 | - throw new INIParseException('Could not parse: ' . $filename, true); |
|
27 | + throw new INIParseException('Could not parse: '.$filename, true); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | * Class INIConfiguration |
9 | 9 | * @package LunixREST\Configuration |
10 | 10 | */ |
11 | -class INIConfiguration implements Configuration |
|
12 | -{ |
|
11 | +class INIConfiguration implements Configuration { |
|
13 | 12 | /** |
14 | 13 | * @var |
15 | 14 | */ |
@@ -19,8 +18,7 @@ discard block |
||
19 | 18 | * @param string $filename |
20 | 19 | * @throws INIParseException |
21 | 20 | */ |
22 | - public function __construct($filename) |
|
23 | - { |
|
21 | + public function __construct($filename) { |
|
24 | 22 | $this->config = parse_ini_file($filename, true); |
25 | 23 | |
26 | 24 | if ($this->config === false) { |
@@ -33,8 +31,7 @@ discard block |
||
33 | 31 | * @param $namespace |
34 | 32 | * @return mixed |
35 | 33 | */ |
36 | - public function get($key, $namespace) |
|
37 | - { |
|
34 | + public function get($key, $namespace) { |
|
38 | 35 | return $this->config[$namespace][$key] ?? null; |
39 | 36 | } |
40 | 37 |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Exceptions; |
3 | 3 | |
4 | -class INIParseException extends \Exception |
|
5 | -{ |
|
4 | +class INIParseException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |