@@ -14,8 +14,7 @@ discard block |
||
| 14 | 14 | use LunixREST\Server\Exceptions\MethodNotFoundException; |
| 15 | 15 | use LunixREST\Throttle\Throttle; |
| 16 | 16 | |
| 17 | -class GenericServer implements Server |
|
| 18 | -{ |
|
| 17 | +class GenericServer implements Server { |
|
| 19 | 18 | /** |
| 20 | 19 | * @var AccessControl |
| 21 | 20 | */ |
@@ -86,8 +85,7 @@ discard block |
||
| 86 | 85 | * @param APIRequest $request |
| 87 | 86 | * @throws InvalidAPIKeyException |
| 88 | 87 | */ |
| 89 | - protected function validateKey(APIRequest $request) |
|
| 90 | - { |
|
| 88 | + protected function validateKey(APIRequest $request) { |
|
| 91 | 89 | if (!$this->accessControl->validateKey($request->getApiKey())) { |
| 92 | 90 | throw new InvalidAPIKeyException('Invalid API key'); |
| 93 | 91 | } |
@@ -98,8 +96,7 @@ discard block |
||
| 98 | 96 | * @throws NotAcceptableResponseTypeException |
| 99 | 97 | */ |
| 100 | 98 | //TODO: Handle wildcards in request MIME types (*/*) |
| 101 | - protected function validateAcceptableMIMETypes(APIRequest $request) |
|
| 102 | - { |
|
| 99 | + protected function validateAcceptableMIMETypes(APIRequest $request) { |
|
| 103 | 100 | $formats = $this->responseFactory->getSupportedMIMETypes(); |
| 104 | 101 | if (empty($formats) || ( |
| 105 | 102 | !empty($request->getAcceptableMIMETypes()) && empty(array_intersect($request->getAcceptableMIMETypes(), |
@@ -10,8 +10,7 @@ |
||
| 10 | 10 | * Interface Router |
| 11 | 11 | * @package LunixREST\Server |
| 12 | 12 | */ |
| 13 | -interface Router |
|
| 14 | -{ |
|
| 13 | +interface Router { |
|
| 15 | 14 | /** |
| 16 | 15 | * @param APIRequest $request |
| 17 | 16 | * @return array|null|object |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $body = $response->getBody(); |
| 93 | - while(!$body->eof()) { |
|
| 93 | + while (!$body->eof()) { |
|
| 94 | 94 | echo $body->read(1024); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | use Psr\Log\LoggerAwareTrait; |
| 16 | 16 | use Psr\Log\LoggerInterface; |
| 17 | 17 | |
| 18 | -class HTTPServer |
|
| 19 | -{ |
|
| 18 | +class HTTPServer { |
|
| 20 | 19 | use LoggerAwareTrait; |
| 21 | 20 | |
| 22 | 21 | /** |
@@ -34,8 +33,7 @@ discard block |
||
| 34 | 33 | * @param RequestFactory $requestFactory |
| 35 | 34 | * @param LoggerInterface $logger |
| 36 | 35 | */ |
| 37 | - public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
| 38 | - { |
|
| 36 | + public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
| 39 | 37 | $this->server = $server; |
| 40 | 38 | $this->requestFactory = $requestFactory; |
| 41 | 39 | $this->logger = $logger; |
@@ -65,8 +63,7 @@ discard block |
||
| 65 | 63 | } |
| 66 | 64 | } |
| 67 | 65 | |
| 68 | - protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) |
|
| 69 | - { |
|
| 66 | + protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) { |
|
| 70 | 67 | try { |
| 71 | 68 | $APIResponse = $this->server->handleRequest($APIRequest); |
| 72 | 69 | |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | * Interface Server |
| 16 | 16 | * @package LunixREST\Server |
| 17 | 17 | */ |
| 18 | -interface Server |
|
| 19 | -{ |
|
| 18 | +interface Server { |
|
| 20 | 19 | /** |
| 21 | 20 | * @param APIRequest $request |
| 22 | 21 | * @return APIResponse |
@@ -7,8 +7,7 @@ |
||
| 7 | 7 | * Class APIResponse |
| 8 | 8 | * @package LunixREST\APIResponse |
| 9 | 9 | */ |
| 10 | -interface APIResponse |
|
| 11 | -{ |
|
| 10 | +interface APIResponse { |
|
| 12 | 11 | /** |
| 13 | 12 | * @return null|object|array |
| 14 | 13 | */ |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace LunixREST\Response\Exceptions; |
| 3 | 3 | |
| 4 | -class NotAcceptableResponseTypeException extends \Exception |
|
| 5 | -{ |
|
| 4 | +class NotAcceptableResponseTypeException extends \Exception { |
|
| 6 | 5 | |
| 7 | 6 | } |
@@ -3,8 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use LunixREST\Response\Exceptions\NotAcceptableResponseTypeException; |
| 5 | 5 | |
| 6 | -interface ResponseFactory |
|
| 7 | -{ |
|
| 6 | +interface ResponseFactory { |
|
| 8 | 7 | /** |
| 9 | 8 | * @param ResponseData $data |
| 10 | 9 | * @param array $acceptedMIMETypes - acceptable MIME types in order of preference |
@@ -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 | |