@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | * Class OneKeyAccessControl |
| 9 | 9 | * @package LunixREST\AccessControl |
| 10 | 10 | */ |
| 11 | -class OneKeyAccessControl implements AccessControl |
|
| 12 | -{ |
|
| 11 | +class OneKeyAccessControl implements AccessControl { |
|
| 13 | 12 | /** |
| 14 | 13 | * @var string |
| 15 | 14 | */ |
@@ -18,8 +17,7 @@ discard block |
||
| 18 | 17 | /** |
| 19 | 18 | * @param string $key |
| 20 | 19 | */ |
| 21 | - public function __construct($key) |
|
| 22 | - { |
|
| 20 | + public function __construct($key) { |
|
| 23 | 21 | $this->key = $key; |
| 24 | 22 | } |
| 25 | 23 | |
@@ -27,8 +25,7 @@ discard block |
||
| 27 | 25 | * @param \LunixREST\APIRequest\APIRequest $request |
| 28 | 26 | * @return bool true if key is valid |
| 29 | 27 | */ |
| 30 | - public function validateAccess(APIRequest $request) |
|
| 31 | - { |
|
| 28 | + public function validateAccess(APIRequest $request) { |
|
| 32 | 29 | return $this->validateKey($request->getApiKey()); |
| 33 | 30 | } |
| 34 | 31 | |
@@ -36,8 +33,7 @@ discard block |
||
| 36 | 33 | * @param $apiKey |
| 37 | 34 | * @return bool true if key is the key specified in the constructor |
| 38 | 35 | */ |
| 39 | - public function validateKey($apiKey) |
|
| 40 | - { |
|
| 36 | + public function validateKey($apiKey) { |
|
| 41 | 37 | return $apiKey === $this->key; |
| 42 | 38 | } |
| 43 | 39 | } |
@@ -3,8 +3,7 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use LunixREST\APIRequest\APIRequest; |
| 5 | 5 | |
| 6 | -class NoThrottle implements Throttle |
|
| 7 | -{ |
|
| 6 | +class NoThrottle implements Throttle { |
|
| 8 | 7 | /** |
| 9 | 8 | * Never throttle |
| 10 | 9 | * @param \LunixREST\APIRequest\APIRequest $request |
@@ -19,8 +18,7 @@ discard block |
||
| 19 | 18 | * Log that a request took place |
| 20 | 19 | * @param \LunixREST\APIRequest\APIRequest $request |
| 21 | 20 | */ |
| 22 | - public function logRequest(APIRequest $request) |
|
| 23 | - { |
|
| 21 | + public function logRequest(APIRequest $request) { |
|
| 24 | 22 | //Do nothing |
| 25 | 23 | } |
| 26 | 24 | } |
@@ -55,10 +55,10 @@ |
||
| 55 | 55 | public function __construct( |
| 56 | 56 | string $method, |
| 57 | 57 | string $endpoint, |
| 58 | - ?string $element, |
|
| 58 | + ? string $element, |
|
| 59 | 59 | array $acceptableMIMETypes, |
| 60 | - ?string $version, |
|
| 61 | - ?string $apiKey, |
|
| 60 | + ? string $version, |
|
| 61 | + ? string $apiKey, |
|
| 62 | 62 | array $queryData, |
| 63 | 63 | $data |
| 64 | 64 | ) { |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | * Class APIRequest |
| 7 | 7 | * @package LunixREST\Request |
| 8 | 8 | */ |
| 9 | -class APIRequest |
|
| 10 | -{ |
|
| 9 | +class APIRequest { |
|
| 11 | 10 | /** |
| 12 | 11 | * @var string |
| 13 | 12 | */ |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | /** |
| 92 | 91 | * @return null|string |
| 93 | 92 | */ |
| 94 | - public function getElement() |
|
| 95 | - { |
|
| 93 | + public function getElement() { |
|
| 96 | 94 | return $this->element; |
| 97 | 95 | } |
| 98 | 96 | |
@@ -107,16 +105,14 @@ discard block |
||
| 107 | 105 | /** |
| 108 | 106 | * @return null|string |
| 109 | 107 | */ |
| 110 | - public function getVersion() |
|
| 111 | - { |
|
| 108 | + public function getVersion() { |
|
| 112 | 109 | return $this->version; |
| 113 | 110 | } |
| 114 | 111 | |
| 115 | 112 | /** |
| 116 | 113 | * @return null|string |
| 117 | 114 | */ |
| 118 | - public function getApiKey() |
|
| 119 | - { |
|
| 115 | + public function getApiKey() { |
|
| 120 | 116 | return $this->apiKey; |
| 121 | 117 | } |
| 122 | 118 | |
@@ -131,8 +127,7 @@ discard block |
||
| 131 | 127 | /** |
| 132 | 128 | * @return array|null|object |
| 133 | 129 | */ |
| 134 | - public function getData() |
|
| 135 | - { |
|
| 130 | + public function getData() { |
|
| 136 | 131 | return $this->data; |
| 137 | 132 | } |
| 138 | 133 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * @param array $acceptableMIMETypes |
| 38 | 38 | * @param null|string $queryString |
| 39 | 39 | */ |
| 40 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
| 40 | + public function __construct(string $endpoint, ? string $element, ? string $version, ? string $apiKey, array $acceptableMIMETypes, ? string $queryString) |
|
| 41 | 41 | { |
| 42 | 42 | $this->endpoint = $endpoint; |
| 43 | 43 | $this->element = $element; |
@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace LunixREST\APIRequest\URLParser; |
| 3 | 3 | |
| 4 | -class ParsedURL |
|
| 5 | -{ |
|
| 4 | +class ParsedURL { |
|
| 6 | 5 | /** |
| 7 | 6 | * @var string |
| 8 | 7 | */ |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | * @param array $acceptableMIMETypes |
| 38 | 37 | * @param null|string $queryString |
| 39 | 38 | */ |
| 40 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
| 41 | - { |
|
| 39 | + public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) { |
|
| 42 | 40 | $this->endpoint = $endpoint; |
| 43 | 41 | $this->element = $element; |
| 44 | 42 | $this->version = $version; |
@@ -58,24 +56,21 @@ discard block |
||
| 58 | 56 | /** |
| 59 | 57 | * @return null|string |
| 60 | 58 | */ |
| 61 | - public function getElement() |
|
| 62 | - { |
|
| 59 | + public function getElement() { |
|
| 63 | 60 | return $this->element; |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | /** |
| 67 | 64 | * @return null|string |
| 68 | 65 | */ |
| 69 | - public function getVersion() |
|
| 70 | - { |
|
| 66 | + public function getVersion() { |
|
| 71 | 67 | return $this->version; |
| 72 | 68 | } |
| 73 | 69 | |
| 74 | 70 | /** |
| 75 | 71 | * @return null|string |
| 76 | 72 | */ |
| 77 | - public function getApiKey() |
|
| 78 | - { |
|
| 73 | + public function getApiKey() { |
|
| 79 | 74 | return $this->apiKey; |
| 80 | 75 | } |
| 81 | 76 | |
@@ -90,8 +85,7 @@ discard block |
||
| 90 | 85 | /** |
| 91 | 86 | * @return null|string |
| 92 | 87 | */ |
| 93 | - public function getQueryString() |
|
| 94 | - { |
|
| 88 | + public function getQueryString() { |
|
| 95 | 89 | return $this->queryString; |
| 96 | 90 | } |
| 97 | 91 | } |
@@ -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 | */ |