@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | use LunixREST\Server\Exceptions\ThrottleLimitExceededException; |
14 | 14 | use LunixREST\Throttle\Throttle; |
15 | 15 | |
16 | -class GenericServer implements Server |
|
17 | -{ |
|
16 | +class GenericServer implements Server { |
|
18 | 17 | /** |
19 | 18 | * @var AccessControl |
20 | 19 | */ |
@@ -85,8 +84,7 @@ discard block |
||
85 | 84 | * @param APIRequest $request |
86 | 85 | * @throws InvalidAPIKeyException |
87 | 86 | */ |
88 | - protected function validateKey(APIRequest $request) |
|
89 | - { |
|
87 | + protected function validateKey(APIRequest $request) { |
|
90 | 88 | if (!$this->accessControl->validateKey($request->getApiKey())) { |
91 | 89 | throw new InvalidAPIKeyException('Invalid API key'); |
92 | 90 | } |
@@ -97,8 +95,7 @@ discard block |
||
97 | 95 | * @throws NotAcceptableResponseTypeException |
98 | 96 | */ |
99 | 97 | //TODO: Handle wildcards in request MIME types (*/*) |
100 | - protected function validateAcceptableMIMETypes(APIRequest $request) |
|
101 | - { |
|
98 | + protected function validateAcceptableMIMETypes(APIRequest $request) { |
|
102 | 99 | $formats = $this->responseFactory->getSupportedMIMETypes(); |
103 | 100 | if (empty($formats) || ( |
104 | 101 | !empty($request->getAcceptableMIMETypes()) && empty(array_intersect($request->getAcceptableMIMETypes(), |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Server\Exceptions; |
3 | 3 | |
4 | -class AccessDeniedException extends \Exception |
|
5 | -{ |
|
4 | +class AccessDeniedException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Server\Exceptions; |
3 | 3 | |
4 | -class InvalidAPIKeyException extends \Exception |
|
5 | -{ |
|
4 | +class InvalidAPIKeyException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Server\Exceptions; |
3 | 3 | |
4 | -class ThrottleLimitExceededException extends \Exception |
|
5 | -{ |
|
4 | +class ThrottleLimitExceededException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * Interface Endpoint |
10 | 10 | * @package LunixREST\Endpoints |
11 | 11 | */ |
12 | -interface Endpoint |
|
13 | -{ |
|
12 | +interface Endpoint { |
|
14 | 13 | /** |
15 | 14 | * @param APIRequest $request |
16 | 15 | * @return APIResponseData |
@@ -9,8 +9,7 @@ |
||
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 APIResponseData |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * Class APIResponse |
8 | 8 | * @package LunixREST\APIResponse |
9 | 9 | */ |
10 | -class APIResponse |
|
11 | -{ |
|
10 | +class APIResponse { |
|
12 | 11 | /** |
13 | 12 | * @var string |
14 | 13 | */ |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | */ |
19 | 18 | protected $stream; |
20 | 19 | |
21 | - public function __construct(string $MIMEType, StreamInterface $stream) |
|
22 | - { |
|
20 | + public function __construct(string $MIMEType, StreamInterface $stream) { |
|
23 | 21 | $this->MIMEType = $MIMEType; |
24 | 22 | $this->stream = $stream; |
25 | 23 | } |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * APIResponseData constructor. |
9 | 9 | * @param null|object|array $data |
10 | 10 | */ |
11 | - public function __construct($data) |
|
12 | - { |
|
11 | + public function __construct($data) { |
|
13 | 12 | $this->data = $data; |
14 | 13 | } |
15 | 14 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($responseTypes = []) |
22 | 22 | { |
23 | - foreach($responseTypes as $mimeType => $serializer) { |
|
23 | + foreach ($responseTypes as $mimeType => $serializer) { |
|
24 | 24 | $this->registerSerializer($mimeType, $serializer); |
25 | 25 | } |
26 | 26 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | foreach ($acceptedMIMETypes as $acceptedMIMEType) { |
46 | - if(isset($this->serializers[strtolower($acceptedMIMEType)])) { |
|
46 | + if (isset($this->serializers[strtolower($acceptedMIMEType)])) { |
|
47 | 47 | return new APIResponse($acceptedMIMEType, $this->serializers[strtolower($acceptedMIMEType)]->serialize($data)); |
48 | 48 | } |
49 | 49 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * Class RegisteredResponseFactory |
8 | 8 | * @package LunixRESTBasics\APIResponse |
9 | 9 | */ |
10 | -class RegisteredResponseFactory implements ResponseFactory |
|
11 | -{ |
|
10 | +class RegisteredResponseFactory implements ResponseFactory { |
|
12 | 11 | /** |
13 | 12 | * @var APIResponseDataSerializer[] |
14 | 13 | */ |
@@ -18,15 +17,13 @@ discard block |
||
18 | 17 | * RegisteredResponseFactory constructor. |
19 | 18 | * @param APIResponseDataSerializer[] $responseTypes |
20 | 19 | */ |
21 | - public function __construct($responseTypes = []) |
|
22 | - { |
|
20 | + public function __construct($responseTypes = []) { |
|
23 | 21 | foreach($responseTypes as $mimeType => $serializer) { |
24 | 22 | $this->registerSerializer($mimeType, $serializer); |
25 | 23 | } |
26 | 24 | } |
27 | 25 | |
28 | - public function registerSerializer($mimeType, APIResponseDataSerializer $dataSerializer) |
|
29 | - { |
|
26 | + public function registerSerializer($mimeType, APIResponseDataSerializer $dataSerializer) { |
|
30 | 27 | $this->serializers[strtolower($mimeType)] = $dataSerializer; |
31 | 28 | } |
32 | 29 |