@@ -28,8 +28,7 @@ |
||
28 | 28 | * Class GenericRouterGenericServer |
29 | 29 | * @package LunixREST\Server |
30 | 30 | */ |
31 | -class GenericRouterGenericServer extends GenericServer |
|
32 | -{ |
|
31 | +class GenericRouterGenericServer extends GenericServer { |
|
33 | 32 | /** |
34 | 33 | * GenericRouterGenericServer constructor. |
35 | 34 | * @param AccessControl $accessControl |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | |
29 | 29 | protected function handleServerException(UnableToHandleRequestException $exception, ResponseInterface $response): ResponseInterface |
30 | 30 | { |
31 | - if($exception instanceof InvalidRequestException) { |
|
31 | + if ($exception instanceof InvalidRequestException) { |
|
32 | 32 | $this->logCaughtThrowableResultingInHTTPCode(400, $exception, LogLevel::INFO); |
33 | 33 | return $response->withStatus(400, "Bad Request"); |
34 | 34 | |
35 | - } elseif( |
|
35 | + } elseif ( |
|
36 | 36 | $exception instanceof ElementNotFoundException || |
37 | 37 | $exception instanceof UnsupportedMethodException || |
38 | 38 | $exception instanceof UnableToCreateEndpointException |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | $this->logCaughtThrowableResultingInHTTPCode(404, $exception, LogLevel::INFO); |
41 | 41 | return $response->withStatus(404, "Not Found"); |
42 | 42 | |
43 | - } elseif($exception instanceof ElementConflictException) { |
|
43 | + } elseif ($exception instanceof ElementConflictException) { |
|
44 | 44 | $this->logCaughtThrowableResultingInHTTPCode(409, $exception, LogLevel::NOTICE); |
45 | 45 | return $response->withStatus(409, "Conflict"); |
46 | 46 | |
47 | - } elseif( |
|
47 | + } elseif ( |
|
48 | 48 | $exception instanceof MethodNotFoundException || |
49 | 49 | $exception instanceof EndpointExecutionException |
50 | 50 | ) { |
@@ -19,10 +19,8 @@ |
||
19 | 19 | * Class GenericRouterGenericServerHTTPServer |
20 | 20 | * @package LunixREST |
21 | 21 | */ |
22 | -class GenericRouterGenericServerHTTPServer extends GenericServerHTTPServer |
|
23 | -{ |
|
24 | - public function __construct(GenericRouterGenericServer $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
25 | - { |
|
22 | +class GenericRouterGenericServerHTTPServer extends GenericServerHTTPServer { |
|
23 | + public function __construct(GenericRouterGenericServer $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
26 | 24 | parent::__construct($server, $requestFactory, $logger); |
27 | 25 | } |
28 | 26 |
@@ -39,19 +39,19 @@ |
||
39 | 39 | */ |
40 | 40 | protected function handleServerException(UnableToHandleRequestException $exception, ResponseInterface $response): ResponseInterface |
41 | 41 | { |
42 | - if($exception instanceof InvalidAPIKeyException || $exception instanceof AccessDeniedException) { |
|
42 | + if ($exception instanceof InvalidAPIKeyException || $exception instanceof AccessDeniedException) { |
|
43 | 43 | $this->logCaughtThrowableResultingInHTTPCode(403, $exception, LogLevel::NOTICE); |
44 | 44 | return $response->withStatus(403, "Access Denied"); |
45 | 45 | |
46 | - } elseif($exception instanceof ThrottleLimitExceededException) { |
|
46 | + } elseif ($exception instanceof ThrottleLimitExceededException) { |
|
47 | 47 | $this->logCaughtThrowableResultingInHTTPCode(429, $exception, LogLevel::WARNING); |
48 | 48 | return $response->withStatus(429, "Too Many Requests"); |
49 | 49 | |
50 | - } elseif($exception instanceof NotAcceptableResponseTypeException) { |
|
50 | + } elseif ($exception instanceof NotAcceptableResponseTypeException) { |
|
51 | 51 | $this->logCaughtThrowableResultingInHTTPCode(406, $exception, LogLevel::INFO); |
52 | 52 | return $response->withStatus(406, "Not Acceptable"); |
53 | 53 | |
54 | - } elseif( |
|
54 | + } elseif ( |
|
55 | 55 | $exception instanceof UnableToCreateAPIResponseException || |
56 | 56 | $exception instanceof UnableToRouteRequestException |
57 | 57 | ) { |
@@ -19,16 +19,14 @@ |
||
19 | 19 | * Class GenericServerHTTPServer |
20 | 20 | * @package LunixREST |
21 | 21 | */ |
22 | -class GenericServerHTTPServer extends HTTPServer |
|
23 | -{ |
|
22 | +class GenericServerHTTPServer extends HTTPServer { |
|
24 | 23 | /** |
25 | 24 | * GenericServerHTTPServer constructor. |
26 | 25 | * @param GenericServer $server |
27 | 26 | * @param RequestFactory $requestFactory |
28 | 27 | * @param LoggerInterface $logger |
29 | 28 | */ |
30 | - public function __construct(GenericServer $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
31 | - { |
|
29 | + public function __construct(GenericServer $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
32 | 30 | parent::__construct($server, $requestFactory, $logger); |
33 | 31 | } |
34 | 32 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | * Class HTTPServer |
18 | 18 | * @package LunixREST |
19 | 19 | */ |
20 | -class HTTPServer |
|
21 | -{ |
|
20 | +class HTTPServer { |
|
22 | 21 | use LoggerAwareTrait; |
23 | 22 | |
24 | 23 | /** |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | * @param RequestFactory $requestFactory |
37 | 36 | * @param LoggerInterface $logger |
38 | 37 | */ |
39 | - public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
40 | - { |
|
38 | + public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
41 | 39 | $this->server = $server; |
42 | 40 | $this->requestFactory = $requestFactory; |
43 | 41 | $this->logger = $logger; |
@@ -115,8 +113,7 @@ discard block |
||
115 | 113 | * Dumps a PSR-7 ResponseInterface to the SAPI. |
116 | 114 | * @param ResponseInterface $response |
117 | 115 | */ |
118 | - public static function dumpResponse(ResponseInterface $response) |
|
119 | - { |
|
116 | + public static function dumpResponse(ResponseInterface $response) { |
|
120 | 117 | $statusLine = sprintf( |
121 | 118 | "HTTP/%s %d %s", |
122 | 119 | $response->getProtocolVersion(), |