@@ -30,6 +30,6 @@ |
||
30 | 30 | */ |
31 | 31 | protected function deriveCacheKey(APIRequest $request): string |
32 | 32 | { |
33 | - return $this->keyPrefix . $request->getApiKey(); |
|
33 | + return $this->keyPrefix.$request->getApiKey(); |
|
34 | 34 | } |
35 | 35 | } |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | * Class APIKeyCachePoolThrottle |
9 | 9 | * @package LunixREST\Server\Throttle |
10 | 10 | */ |
11 | -class APIKeyCachePoolThrottle extends CachePoolThrottle |
|
12 | -{ |
|
11 | +class APIKeyCachePoolThrottle extends CachePoolThrottle { |
|
13 | 12 | /** |
14 | 13 | * @var string |
15 | 14 | */ |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | * @param int $perXSeconds |
23 | 22 | * @param string $keyPrefix |
24 | 23 | */ |
25 | - public function __construct(CacheItemPoolInterface $cacheItemPool, $limit = 60, $perXSeconds = 60, $keyPrefix = '') |
|
26 | - { |
|
24 | + public function __construct(CacheItemPoolInterface $cacheItemPool, $limit = 60, $perXSeconds = 60, $keyPrefix = '') { |
|
27 | 25 | parent::__construct($cacheItemPool, $limit, $perXSeconds); |
28 | 26 | $this->keyPrefix = $keyPrefix; |
29 | 27 | } |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * Class PublicAccessControl |
9 | 9 | * @package LunixREST\Server\AccessControl |
10 | 10 | */ |
11 | -class PublicAccessControl implements AccessControl |
|
12 | -{ |
|
11 | +class PublicAccessControl implements AccessControl { |
|
13 | 12 | /** |
14 | 13 | * @param \LunixREST\Server\APIRequest\APIRequest $request |
15 | 14 | * @return bool |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * Interface AccessControl |
9 | 9 | * @package LunixREST\Server\AccessControl |
10 | 10 | */ |
11 | -interface AccessControl |
|
12 | -{ |
|
11 | +interface AccessControl { |
|
13 | 12 | /** |
14 | 13 | * Validates if a given request should be able to access what it's trying to |
15 | 14 | * @param APIRequest $request |
@@ -14,8 +14,7 @@ |
||
14 | 14 | * Interface Endpoint |
15 | 15 | * @package LunixREST\Server\Router\Endpoint |
16 | 16 | */ |
17 | -interface Endpoint |
|
18 | -{ |
|
17 | +interface Endpoint { |
|
19 | 18 | /** |
20 | 19 | * @param APIRequest $request |
21 | 20 | * @return APIResponseData |
@@ -13,8 +13,7 @@ |
||
13 | 13 | * Class Endpoint |
14 | 14 | * @package LunixREST\Server\Router\Endpoint |
15 | 15 | */ |
16 | -class DefaultEndpoint implements Endpoint |
|
17 | -{ |
|
16 | +class DefaultEndpoint implements Endpoint { |
|
18 | 17 | /** |
19 | 18 | * @param APIRequest $request |
20 | 19 | * @return APIResponseData |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function register(string $name, string $version, Endpoint $endpoint) |
24 | 24 | { |
25 | - if(!isset($this->endpoints[$version])) { |
|
25 | + if (!isset($this->endpoints[$version])) { |
|
26 | 26 | $this->endpoints[$version] = []; |
27 | 27 | } |
28 | 28 | $this->endpoints[$version][strtolower($name)] = $endpoint; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public function getEndpoint(string $name, string $version): Endpoint |
38 | 38 | { |
39 | 39 | $lowercaseName = strtolower($name); |
40 | - if(!isset($this->endpoints[$version]) || !isset($this->endpoints[$version][$lowercaseName])) { |
|
41 | - throw new UnknownEndpointException('Could not find endpoint: ' . $name . ' of version: ' . $version); |
|
40 | + if (!isset($this->endpoints[$version]) || !isset($this->endpoints[$version][$lowercaseName])) { |
|
41 | + throw new UnknownEndpointException('Could not find endpoint: '.$name.' of version: '.$version); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return $this->endpoints[$version][$lowercaseName]; |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * Class RegisteredEndpointFactory |
11 | 11 | * @package LunixREST\Server\Router\EndpointFactory |
12 | 12 | */ |
13 | -class RegisteredEndpointFactory implements EndpointFactory |
|
14 | -{ |
|
13 | +class RegisteredEndpointFactory implements EndpointFactory { |
|
15 | 14 | /** |
16 | 15 | * @var Endpoint[][] |
17 | 16 | */ |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | * @param string $version |
23 | 22 | * @param Endpoint $endpoint |
24 | 23 | */ |
25 | - public function register(string $name, string $version, Endpoint $endpoint) |
|
26 | - { |
|
24 | + public function register(string $name, string $version, Endpoint $endpoint) { |
|
27 | 25 | if(!isset($this->endpoints[$version])) { |
28 | 26 | $this->endpoints[$version] = []; |
29 | 27 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * Interface EndpointFactory |
10 | 10 | * @package LunixREST\Server\Router\Endpoint |
11 | 11 | */ |
12 | -interface EndpointFactory |
|
13 | -{ |
|
12 | +interface EndpointFactory { |
|
14 | 13 | /** |
15 | 14 | * @param string $name |
16 | 15 | * @param string $version |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $method = $this->mapEndpointMethod($request); |
60 | 60 | if (!method_exists($endpoint, $method)) { |
61 | - throw new MethodNotFoundException("The endpoint method " . $method . " was not found"); |
|
61 | + throw new MethodNotFoundException("The endpoint method ".$method." was not found"); |
|
62 | 62 | } |
63 | 63 | return call_user_func([$endpoint, $method], $request); |
64 | 64 | } |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function mapEndpointMethod(APIRequest $request): string |
71 | 71 | { |
72 | - return strtolower($request->getMethod()) . (!$request->getElement() ? 'All': ''); |
|
72 | + return strtolower($request->getMethod()).(!$request->getElement() ? 'All' : ''); |
|
73 | 73 | } |
74 | 74 | } |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | * Class GenericRouter |
16 | 16 | * @package LunixREST\Server\Router |
17 | 17 | */ |
18 | -class GenericRouter implements Router |
|
19 | -{ |
|
18 | +class GenericRouter implements Router { |
|
20 | 19 | /** |
21 | 20 | * @var EndpointFactory |
22 | 21 | */ |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | * DefaultRouter constructor. |
27 | 26 | * @param EndpointFactory $endpointFactory |
28 | 27 | */ |
29 | - public function __construct(EndpointFactory $endpointFactory) |
|
30 | - { |
|
28 | + public function __construct(EndpointFactory $endpointFactory) { |
|
31 | 29 | $this->endpointFactory = $endpointFactory; |
32 | 30 | } |
33 | 31 |
@@ -14,8 +14,7 @@ |
||
14 | 14 | * Interface Router |
15 | 15 | * @package LunixREST\Server\Router |
16 | 16 | */ |
17 | -interface Router |
|
18 | -{ |
|
17 | +interface Router { |
|
19 | 18 | /** |
20 | 19 | * @param APIRequest $request |
21 | 20 | * @return APIResponseData |