@@ -7,8 +7,7 @@ |
||
7 | 7 | * Interface Throttle |
8 | 8 | * @package LunixREST\Throttle |
9 | 9 | */ |
10 | -interface Throttle |
|
11 | -{ |
|
10 | +interface Throttle { |
|
12 | 11 | /** |
13 | 12 | * Returns true if the given request should be throttled in our implementation |
14 | 13 | * @param \LunixREST\Request\Request $request |
@@ -7,8 +7,7 @@ |
||
7 | 7 | * Interface AccessControl |
8 | 8 | * @package LunixREST\AccessControl |
9 | 9 | */ |
10 | -interface AccessControl |
|
11 | -{ |
|
10 | +interface AccessControl { |
|
12 | 11 | /** |
13 | 12 | * Validates if a given request should be able to access what it's trying to |
14 | 13 | * @param $request |
@@ -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 | { |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use LunixREST\Request\BodyParser\Exceptions\InvalidRequestDataException; |
5 | 5 | |
6 | -class JSONRequestData implements RequestData |
|
7 | -{ |
|
6 | +class JSONRequestData implements RequestData { |
|
8 | 7 | |
9 | 8 | protected $jsonString; |
10 | 9 | |
@@ -15,8 +14,7 @@ discard block |
||
15 | 14 | * @param $body |
16 | 15 | * @throws InvalidRequestDataException |
17 | 16 | */ |
18 | - public function __construct($body) |
|
19 | - { |
|
17 | + public function __construct($body) { |
|
20 | 18 | $this->jsonString = $body; |
21 | 19 | $this->parsedData = json_decode($body, true); |
22 | 20 | if ($this->parsedData === null) { |
@@ -40,8 +38,7 @@ discard block |
||
40 | 38 | * @param string $key |
41 | 39 | * @return mixed |
42 | 40 | */ |
43 | - public function get(string $key) |
|
44 | - { |
|
41 | + public function get(string $key) { |
|
45 | 42 | return $this->parsedData[$key] ?? null; |
46 | 43 | } |
47 | 44 |
@@ -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 | } |
@@ -3,8 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use LunixREST\Request\URLParser\Exceptions\InvalidRequestURLException; |
5 | 5 | |
6 | -interface URLParser |
|
7 | -{ |
|
6 | +interface URLParser { |
|
8 | 7 | /** |
9 | 8 | * Parses API request data out of a url |
10 | 9 | * @param $url |