@@ -4,8 +4,7 @@ |
||
| 4 | 4 | use LunixREST\Request\BodyParser\Exceptions\InvalidRequestDataException; |
| 5 | 5 | use LunixREST\Request\RequestData\RequestData; |
| 6 | 6 | |
| 7 | -interface BodyParser |
|
| 8 | -{ |
|
| 7 | +interface BodyParser { |
|
| 9 | 8 | /** |
| 10 | 9 | * Parses API request data out of a url |
| 11 | 10 | * @param $rawBody |
@@ -5,8 +5,7 @@ |
||
| 5 | 5 | use LunixREST\Request\RequestData\RequestData; |
| 6 | 6 | use LunixREST\Request\RequestData\URLEncodedQueryStringRequestData; |
| 7 | 7 | |
| 8 | -class URLEncodedBodyParser implements BodyParser |
|
| 9 | -{ |
|
| 8 | +class URLEncodedBodyParser implements BodyParser { |
|
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Parses API request data out of a url |
@@ -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 |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | * Class DefaultRouter |
| 11 | 11 | * @package LunixREST\Server |
| 12 | 12 | */ |
| 13 | -class GenericRouter |
|
| 14 | -{ |
|
| 13 | +class GenericRouter { |
|
| 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"); |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | use Psr\Http\Message\ResponseInterface; |
| 13 | 13 | use Psr\Http\Message\ServerRequestInterface; |
| 14 | 14 | |
| 15 | -class HTTPServer |
|
| 16 | -{ |
|
| 15 | +class HTTPServer { |
|
| 17 | 16 | /** |
| 18 | 17 | * @var Server |
| 19 | 18 | */ |
@@ -30,8 +29,7 @@ discard block |
||
| 30 | 29 | */ |
| 31 | 30 | //TODO: Add RequestLogger that we can pass through to log requests |
| 32 | 31 | //TODO: Add ErrorLogger to log errors (500s) |
| 33 | - public function __construct(Server $server, RequestFactory $requestFactory) |
|
| 34 | - { |
|
| 32 | + public function __construct(Server $server, RequestFactory $requestFactory) { |
|
| 35 | 33 | $this->server = $server; |
| 36 | 34 | $this->requestFactory = $requestFactory; |
| 37 | 35 | } |
@@ -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 | } |