@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * JSONRequestData constructor. |
| 15 | - * @param $body |
|
| 15 | + * @param string $body |
|
| 16 | 16 | * @throws InvalidRequestDataException |
| 17 | 17 | */ |
| 18 | 18 | public function __construct($body) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Attempts to find a specific key in the parsed data. Returns true if found else false |
| 50 | 50 | * @param string $key |
| 51 | - * @return mixed |
|
| 51 | + * @return boolean |
|
| 52 | 52 | */ |
| 53 | 53 | public function has(string $key): bool |
| 54 | 54 | { |
@@ -8,14 +8,12 @@ discard block |
||
| 8 | 8 | * Class PublicAccessControl |
| 9 | 9 | * @package LunixREST\AccessControl |
| 10 | 10 | */ |
| 11 | -class PublicAccessControl implements AccessControl |
|
| 12 | -{ |
|
| 11 | +class PublicAccessControl implements AccessControl { |
|
| 13 | 12 | /** |
| 14 | 13 | * @param \LunixREST\APIRequest\APIRequest $request |
| 15 | 14 | * @return bool |
| 16 | 15 | */ |
| 17 | - public function validateAccess(APIRequest $request) |
|
| 18 | - { |
|
| 16 | + public function validateAccess(APIRequest $request) { |
|
| 19 | 17 | return true; |
| 20 | 18 | } |
| 21 | 19 | |
@@ -23,8 +21,7 @@ discard block |
||
| 23 | 21 | * @param $apiKey |
| 24 | 22 | * @return bool |
| 25 | 23 | */ |
| 26 | - public function validateKey($apiKey) |
|
| 27 | - { |
|
| 24 | + public function validateKey($apiKey) { |
|
| 28 | 25 | return true; |
| 29 | 26 | } |
| 30 | 27 | } |
@@ -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 | } |
@@ -8,14 +8,12 @@ discard block |
||
| 8 | 8 | * Class MultiAccessControl |
| 9 | 9 | * @package LunixREST\AccessControl |
| 10 | 10 | */ |
| 11 | -class MultiAndAccessControl extends MultiAccessControl |
|
| 12 | -{ |
|
| 11 | +class MultiAndAccessControl extends MultiAccessControl { |
|
| 13 | 12 | /** |
| 14 | 13 | * @param \LunixREST\APIRequest\APIRequest $request |
| 15 | 14 | * @return bool true if all of the $accessControls' validate access methods returned true for the given request |
| 16 | 15 | */ |
| 17 | - public function validateAccess(APIRequest $request) |
|
| 18 | - { |
|
| 16 | + public function validateAccess(APIRequest $request) { |
|
| 19 | 17 | foreach ($this->accessControls as $accessControl) { |
| 20 | 18 | if (!$accessControl->validateAccess($request)) { |
| 21 | 19 | return false; |
@@ -28,8 +26,7 @@ discard block |
||
| 28 | 26 | * @param $apiKey |
| 29 | 27 | * @return bool true if all of the $accessControls' validate key methods returned true for the given request |
| 30 | 28 | */ |
| 31 | - public function validateKey($apiKey) |
|
| 32 | - { |
|
| 29 | + public function validateKey($apiKey) { |
|
| 33 | 30 | foreach ($this->accessControls as $accessControl) { |
| 34 | 31 | if (!$accessControl->validateKey($apiKey)) { |
| 35 | 32 | return false; |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * Class AllAccessListAccessControl |
| 10 | 10 | * @package LunixREST\AccessControl |
| 11 | 11 | */ |
| 12 | -class AllAccessConfigurationListAccessControl implements AccessControl |
|
| 13 | -{ |
|
| 12 | +class AllAccessConfigurationListAccessControl implements AccessControl { |
|
| 14 | 13 | /** |
| 15 | 14 | * @var Configuration |
| 16 | 15 | */ |
@@ -25,8 +24,7 @@ discard block |
||
| 25 | 24 | * @param Configuration $config a config that has a list of valid keys in the stored $configKey |
| 26 | 25 | * @param string $configKey key to use when accessing the list of valid keys from the $config |
| 27 | 26 | */ |
| 28 | - public function __construct(Configuration $config, $configKey = 'keys') |
|
| 29 | - { |
|
| 27 | + public function __construct(Configuration $config, $configKey = 'keys') { |
|
| 30 | 28 | $this->config = $config; |
| 31 | 29 | $this->configKey = $configKey; |
| 32 | 30 | } |
@@ -35,8 +33,7 @@ discard block |
||
| 35 | 33 | * @param \LunixREST\APIRequest\APIRequest $request |
| 36 | 34 | * @return bool true if this key is valid |
| 37 | 35 | */ |
| 38 | - public function validateAccess(APIRequest $request) |
|
| 39 | - { |
|
| 36 | + public function validateAccess(APIRequest $request) { |
|
| 40 | 37 | return $this->validateKey($request->getApiKey()); |
| 41 | 38 | } |
| 42 | 39 | |
@@ -44,8 +41,7 @@ discard block |
||
| 44 | 41 | * @param $apiKey |
| 45 | 42 | * @return bool true if the key is found inside of the array returned by the config when $config->get is called with the key from the constructor |
| 46 | 43 | */ |
| 47 | - public function validateKey($apiKey) |
|
| 48 | - { |
|
| 44 | + public function validateKey($apiKey) { |
|
| 49 | 45 | return in_array($apiKey, $this->config->get($this->configKey)); |
| 50 | 46 | } |
| 51 | 47 | } |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * Class AllAccessListAccessControl |
| 10 | 10 | * @package LunixREST\AccessControl |
| 11 | 11 | */ |
| 12 | -class AllAccessListAccessControl implements AccessControl |
|
| 13 | -{ |
|
| 12 | +class AllAccessListAccessControl implements AccessControl { |
|
| 14 | 13 | /** |
| 15 | 14 | * @var array |
| 16 | 15 | */ |
@@ -19,8 +18,7 @@ discard block |
||
| 19 | 18 | /** |
| 20 | 19 | * @param array $keys |
| 21 | 20 | */ |
| 22 | - public function __construct(Array $keys) |
|
| 23 | - { |
|
| 21 | + public function __construct(Array $keys) { |
|
| 24 | 22 | $this->keys = $keys; |
| 25 | 23 | } |
| 26 | 24 | |
@@ -28,8 +26,7 @@ discard block |
||
| 28 | 26 | * @param \LunixREST\APIRequest\APIRequest $request |
| 29 | 27 | * @return bool true if key is valid |
| 30 | 28 | */ |
| 31 | - public function validateAccess(APIRequest $request) |
|
| 32 | - { |
|
| 29 | + public function validateAccess(APIRequest $request) { |
|
| 33 | 30 | return $this->validateKey($request->getApiKey()); |
| 34 | 31 | } |
| 35 | 32 | |
@@ -37,8 +34,7 @@ discard block |
||
| 37 | 34 | * @param $apiKey |
| 38 | 35 | * @return bool true if key is in the array passed to this object in it's construction |
| 39 | 36 | */ |
| 40 | - public function validateKey($apiKey) |
|
| 41 | - { |
|
| 37 | + public function validateKey($apiKey) { |
|
| 42 | 38 | return in_array($apiKey, $this->keys); |
| 43 | 39 | } |
| 44 | 40 | } |
@@ -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 | } |
@@ -47,13 +47,13 @@ |
||
| 47 | 47 | $parsedHeaders = $this->headerParser->parse($serverRequest->getHeaders()); |
| 48 | 48 | |
| 49 | 49 | $urlQueryData = []; |
| 50 | - if($urlQueryString = $parsedURL->getQueryString()) |
|
| 50 | + if ($urlQueryString = $parsedURL->getQueryString()) |
|
| 51 | 51 | { |
| 52 | 52 | parse_str($parsedURL->getQueryString(), $urlQueryData); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $apiKey = $parsedURL->getAPIKey(); |
| 56 | - if($apiKey === null) |
|
| 56 | + if ($apiKey === null) |
|
| 57 | 57 | { |
| 58 | 58 | $apiKey = $parsedHeaders->getAPIKey(); |
| 59 | 59 | } |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | * @param URLParser $URLParser |
| 29 | 29 | * @param HeaderParser $headerParser |
| 30 | 30 | */ |
| 31 | - public function __construct(URLParser $URLParser, HeaderParser $headerParser) |
|
| 32 | - { |
|
| 31 | + public function __construct(URLParser $URLParser, HeaderParser $headerParser) { |
|
| 33 | 32 | $this->URLParser = $URLParser; |
| 34 | 33 | $this->headerParser = $headerParser; |
| 35 | 34 | } |
@@ -47,14 +46,12 @@ discard block |
||
| 47 | 46 | $parsedHeaders = $this->headerParser->parse($serverRequest->getHeaders()); |
| 48 | 47 | |
| 49 | 48 | $urlQueryData = []; |
| 50 | - if($urlQueryString = $parsedURL->getQueryString()) |
|
| 51 | - { |
|
| 49 | + if($urlQueryString = $parsedURL->getQueryString()) { |
|
| 52 | 50 | parse_str($parsedURL->getQueryString(), $urlQueryData); |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | 53 | $apiKey = $parsedURL->getAPIKey(); |
| 56 | - if($apiKey === null) |
|
| 57 | - { |
|
| 54 | + if($apiKey === null) { |
|
| 58 | 55 | $apiKey = $parsedHeaders->getAPIKey(); |
| 59 | 56 | } |
| 60 | 57 | |