@@ -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 | } |
@@ -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 | } |
@@ -1,15 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace LunixREST\Request\RequestData; |
| 3 | 3 | |
| 4 | -class URLEncodedQueryStringRequestData implements RequestData |
|
| 5 | -{ |
|
| 4 | +class URLEncodedQueryStringRequestData implements RequestData { |
|
| 6 | 5 | |
| 7 | 6 | protected $queryString; |
| 8 | 7 | |
| 9 | 8 | protected $parsedData = []; |
| 10 | 9 | |
| 11 | - public function __construct($queryString) |
|
| 12 | - { |
|
| 10 | + public function __construct($queryString) { |
|
| 13 | 11 | $this->queryString = $queryString; |
| 14 | 12 | parse_str($queryString, $this->parsedData); |
| 15 | 13 | } |
@@ -30,8 +28,7 @@ discard block |
||
| 30 | 28 | * @param string $key |
| 31 | 29 | * @return mixed |
| 32 | 30 | */ |
| 33 | - public function get(string $key) |
|
| 34 | - { |
|
| 31 | + public function get(string $key) { |
|
| 35 | 32 | return $this->parsedData[$key] ?? null; |
| 36 | 33 | } |
| 37 | 34 | |
@@ -1,8 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace LunixREST\Request\RequestData; |
| 3 | 3 | |
| 4 | -interface RequestData |
|
| 5 | -{ |
|
| 4 | +interface RequestData { |
|
| 6 | 5 | /** |
| 7 | 6 | * Returns the raw data that the requestData tried to parse |
| 8 | 7 | * @return string |
@@ -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 | |
@@ -10,10 +10,8 @@ |
||
| 10 | 10 | * Class BasicRequestFactory |
| 11 | 11 | * @package LunixREST\Request\RequestFactory |
| 12 | 12 | */ |
| 13 | -class DefaultRequestFactory extends GenericRequestFactory |
|
| 14 | -{ |
|
| 15 | - public function __construct(URLParser $URLParser) |
|
| 16 | - { |
|
| 13 | +class DefaultRequestFactory extends GenericRequestFactory { |
|
| 14 | + public function __construct(URLParser $URLParser) { |
|
| 17 | 15 | parent::__construct($URLParser, new DefaultBodyParserFactory(), new DefaultHeaderParser()); |
| 18 | 16 | } |
| 19 | 17 | } |
@@ -9,10 +9,8 @@ |
||
| 9 | 9 | * Class BasicRequestFactory |
| 10 | 10 | * @package LunixREST\Request\RequestFactory |
| 11 | 11 | */ |
| 12 | -class BasicRequestFactory extends DefaultRequestFactory |
|
| 13 | -{ |
|
| 14 | - public function __construct() |
|
| 15 | - { |
|
| 12 | +class BasicRequestFactory extends DefaultRequestFactory { |
|
| 13 | + public function __construct() { |
|
| 16 | 14 | parent::__construct(new BasicURLParser(new MIMEFileProvider())); |
| 17 | 15 | } |
| 18 | 16 | } |