@@ -6,8 +6,7 @@ |
||
| 6 | 6 | * Interface HeaderParser |
| 7 | 7 | * @package LunixREST\APIRequest\HeaderParser |
| 8 | 8 | */ |
| 9 | -interface HeaderParser |
|
| 10 | -{ |
|
| 9 | +interface HeaderParser { |
|
| 11 | 10 | /** |
| 12 | 11 | * @param array $headers |
| 13 | 12 | * @return ParsedHeaders |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | * Class ElementNotFoundException |
| 7 | 7 | * @package LunixREST\Endpoint\Exceptions |
| 8 | 8 | */ |
| 9 | -class ElementNotFoundException extends \Exception |
|
| 10 | -{ |
|
| 9 | +class ElementNotFoundException extends \Exception { |
|
| 11 | 10 | |
| 12 | 11 | } |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | * Class InvalidRequestException |
| 7 | 7 | * @package LunixREST\Endpoint\Exceptions |
| 8 | 8 | */ |
| 9 | -class InvalidRequestException extends \Exception |
|
| 10 | -{ |
|
| 9 | +class InvalidRequestException extends \Exception { |
|
| 11 | 10 | |
| 12 | 11 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | } catch (InvalidAPIKeyException | AccessDeniedException $e) { |
| 103 | 103 | $this->logCaughtThrowableResultingInHTTPCode(403, $e, LogLevel::NOTICE); |
| 104 | 104 | return $response->withStatus(403, "Access Denied"); |
| 105 | - } catch (ElementConflictException $e) { |
|
| 105 | + } catch (ElementConflictException $e) { |
|
| 106 | 106 | $this->logCaughtThrowableResultingInHTTPCode(409, $e, LogLevel::NOTICE); |
| 107 | 107 | return $response->withStatus(409, "Conflict"); |
| 108 | 108 | } catch (ThrottleLimitExceededException $e) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $body = $response->getBody(); |
| 138 | - while(!$body->eof()) { |
|
| 138 | + while (!$body->eof()) { |
|
| 139 | 139 | echo $body->read(1024); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | * Class HTTPServer |
| 25 | 25 | * @package LunixREST\Server |
| 26 | 26 | */ |
| 27 | -class HTTPServer |
|
| 28 | -{ |
|
| 27 | +class HTTPServer { |
|
| 29 | 28 | use LoggerAwareTrait; |
| 30 | 29 | |
| 31 | 30 | /** |
@@ -43,8 +42,7 @@ discard block |
||
| 43 | 42 | * @param RequestFactory $requestFactory |
| 44 | 43 | * @param LoggerInterface $logger |
| 45 | 44 | */ |
| 46 | - public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
| 47 | - { |
|
| 45 | + public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
| 48 | 46 | $this->server = $server; |
| 49 | 47 | $this->requestFactory = $requestFactory; |
| 50 | 48 | $this->logger = $logger; |
@@ -80,8 +78,7 @@ discard block |
||
| 80 | 78 | * @param ResponseInterface $response |
| 81 | 79 | * @return ResponseInterface |
| 82 | 80 | */ |
| 83 | - protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) |
|
| 84 | - { |
|
| 81 | + protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) { |
|
| 85 | 82 | try { |
| 86 | 83 | $APIResponse = $this->server->handleRequest($APIRequest); |
| 87 | 84 | |
@@ -102,7 +99,7 @@ discard block |
||
| 102 | 99 | } catch (InvalidAPIKeyException | AccessDeniedException $e) { |
| 103 | 100 | $this->logCaughtThrowableResultingInHTTPCode(403, $e, LogLevel::NOTICE); |
| 104 | 101 | return $response->withStatus(403, "Access Denied"); |
| 105 | - } catch (ElementConflictException $e) { |
|
| 102 | + } catch (ElementConflictException $e) { |
|
| 106 | 103 | $this->logCaughtThrowableResultingInHTTPCode(409, $e, LogLevel::NOTICE); |
| 107 | 104 | return $response->withStatus(409, "Conflict"); |
| 108 | 105 | } catch (ThrottleLimitExceededException $e) { |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | * Class ElementConflictException |
| 7 | 7 | * @package LunixREST\Endpoint\Exceptions |
| 8 | 8 | */ |
| 9 | -class ElementConflictException extends \Exception |
|
| 10 | -{ |
|
| 9 | +class ElementConflictException extends \Exception { |
|
| 11 | 10 | |
| 12 | 11 | } |
@@ -21,8 +21,7 @@ discard block |
||
| 21 | 21 | * Class GenericServer |
| 22 | 22 | * @package LunixREST\Server |
| 23 | 23 | */ |
| 24 | -class GenericServer implements Server |
|
| 25 | -{ |
|
| 24 | +class GenericServer implements Server { |
|
| 26 | 25 | /** |
| 27 | 26 | * @var AccessControl |
| 28 | 27 | */ |
@@ -96,8 +95,7 @@ discard block |
||
| 96 | 95 | * @param APIRequest $request |
| 97 | 96 | * @throws InvalidAPIKeyException |
| 98 | 97 | */ |
| 99 | - protected function validateKey(APIRequest $request) |
|
| 100 | - { |
|
| 98 | + protected function validateKey(APIRequest $request) { |
|
| 101 | 99 | if (!$this->accessControl->validateKey($request->getApiKey())) { |
| 102 | 100 | throw new InvalidAPIKeyException('Invalid API key'); |
| 103 | 101 | } |
@@ -107,8 +105,7 @@ discard block |
||
| 107 | 105 | * @param APIRequest $request |
| 108 | 106 | * @throws NotAcceptableResponseTypeException |
| 109 | 107 | */ |
| 110 | - protected function validateAcceptableMIMETypes(APIRequest $request) |
|
| 111 | - { |
|
| 108 | + protected function validateAcceptableMIMETypes(APIRequest $request) { |
|
| 112 | 109 | $supportedFormats = $this->responseFactory->getSupportedMIMETypes(); |
| 113 | 110 | $requestedFormats = $request->getAcceptableMIMETypes(); |
| 114 | 111 | |
@@ -10,8 +10,7 @@ |
||
| 10 | 10 | * Class JSONHTTPServer |
| 11 | 11 | * @package LunixREST\Server |
| 12 | 12 | */ |
| 13 | -class JSONHTTPServer extends HTTPServer |
|
| 14 | -{ |
|
| 13 | +class JSONHTTPServer extends HTTPServer { |
|
| 15 | 14 | /** |
| 16 | 15 | * @param ServerRequestInterface $serverRequest |
| 17 | 16 | * @param ResponseInterface $response |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @param MIMEProvider|null $MIMEProvider |
| 33 | 33 | * @throws InvalidRegexPatternException |
| 34 | 34 | */ |
| 35 | - public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null) |
|
| 35 | + public function __construct(string $pattern, ? MIMEProvider $MIMEProvider = null) |
|
| 36 | 36 | { |
| 37 | 37 | $this->pattern = $pattern; |
| 38 | 38 | |
| 39 | - if(@preg_match($pattern, null) === false) { |
|
| 39 | + if (@preg_match($pattern, null) === false) { |
|
| 40 | 40 | throw new InvalidRegexPatternException("Unable to parse regex pattern", preg_last_error()); |
| 41 | 41 | } |
| 42 | 42 | $this->MIMEProvider = $MIMEProvider; |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | public function parse(UriInterface $uri): ParsedURL |
| 52 | 52 | { |
| 53 | 53 | $matches = []; |
| 54 | - if(preg_match($this->pattern, $uri->getPath(), $matches) === 0) { |
|
| 54 | + if (preg_match($this->pattern, $uri->getPath(), $matches) === 0) { |
|
| 55 | 55 | throw new InvalidRequestURLException("Unable to parse request path: did not match regex"); |
| 56 | 56 | } |
| 57 | - if(!($endpoint = $matches["endpoint"] ?? null)) { |
|
| 57 | + if (!($endpoint = $matches["endpoint"] ?? null)) { |
|
| 58 | 58 | throw new InvalidRequestURLException("Unable to match endpoint in url"); |
| 59 | 59 | } |
| 60 | 60 | $element = $matches["element"] ?? null; |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | $apiKey = $matches["apiKey"] ?? null; |
| 63 | 63 | |
| 64 | 64 | $acceptableMimeTypes = []; |
| 65 | - if(($acceptableExtension = $matches["acceptableExtension"] ?? null)) { |
|
| 66 | - if(!$this->MIMEProvider) { |
|
| 65 | + if (($acceptableExtension = $matches["acceptableExtension"] ?? null)) { |
|
| 66 | + if (!$this->MIMEProvider) { |
|
| 67 | 67 | throw new InvalidRequestURLException("Unable to accept acceptable extensions"); |
| 68 | 68 | } else { |
| 69 | 69 | try { |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | * Class RegexURLParser |
| 16 | 16 | * @package LunixREST\APIRequest\URLParser\RegexURLParser |
| 17 | 17 | */ |
| 18 | -class RegexURLParser implements URLParser |
|
| 19 | -{ |
|
| 18 | +class RegexURLParser implements URLParser { |
|
| 20 | 19 | /** |
| 21 | 20 | * @var string |
| 22 | 21 | */ |
@@ -32,8 +31,7 @@ discard block |
||
| 32 | 31 | * @param MIMEProvider|null $MIMEProvider |
| 33 | 32 | * @throws InvalidRegexPatternException |
| 34 | 33 | */ |
| 35 | - public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null) |
|
| 36 | - { |
|
| 34 | + public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null) { |
|
| 37 | 35 | $this->pattern = $pattern; |
| 38 | 36 | |
| 39 | 37 | if(@preg_match($pattern, null) === false) { |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | * Class InvalidRequestURLException |
| 7 | 7 | * @package LunixREST\APIRequest\URLParser\RegexURLParser\Exceptions |
| 8 | 8 | */ |
| 9 | -class InvalidRegexPatternException extends \Exception |
|
| 10 | -{ |
|
| 9 | +class InvalidRegexPatternException extends \Exception { |
|
| 11 | 10 | |
| 12 | 11 | } |