@@ -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 |
@@ -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 | } |
@@ -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 |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\URLParser\Exceptions; |
3 | 3 | |
4 | -class InvalidRequestURLException extends \Exception |
|
5 | -{ |
|
4 | +class InvalidRequestURLException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param array $acceptableMIMETypes |
38 | 38 | * @param null|string $queryString |
39 | 39 | */ |
40 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
40 | + public function __construct(string $endpoint, ? string $element, ? string $version, ? string $apiKey, array $acceptableMIMETypes, ? string $queryString) |
|
41 | 41 | { |
42 | 42 | $this->endpoint = $endpoint; |
43 | 43 | $this->element = $element; |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\APIRequest\URLParser; |
3 | 3 | |
4 | -class ParsedURL |
|
5 | -{ |
|
4 | +class ParsedURL { |
|
6 | 5 | /** |
7 | 6 | * @var string |
8 | 7 | */ |
@@ -37,8 +36,7 @@ discard block |
||
37 | 36 | * @param array $acceptableMIMETypes |
38 | 37 | * @param null|string $queryString |
39 | 38 | */ |
40 | - public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) |
|
41 | - { |
|
39 | + public function __construct(string $endpoint, ?string $element, ?string $version, ?string $apiKey, array $acceptableMIMETypes, ?string $queryString) { |
|
42 | 40 | $this->endpoint = $endpoint; |
43 | 41 | $this->element = $element; |
44 | 42 | $this->version = $version; |
@@ -58,24 +56,21 @@ discard block |
||
58 | 56 | /** |
59 | 57 | * @return null|string |
60 | 58 | */ |
61 | - public function getElement() |
|
62 | - { |
|
59 | + public function getElement() { |
|
63 | 60 | return $this->element; |
64 | 61 | } |
65 | 62 | |
66 | 63 | /** |
67 | 64 | * @return null|string |
68 | 65 | */ |
69 | - public function getVersion() |
|
70 | - { |
|
66 | + public function getVersion() { |
|
71 | 67 | return $this->version; |
72 | 68 | } |
73 | 69 | |
74 | 70 | /** |
75 | 71 | * @return null|string |
76 | 72 | */ |
77 | - public function getApiKey() |
|
78 | - { |
|
73 | + public function getApiKey() { |
|
79 | 74 | return $this->apiKey; |
80 | 75 | } |
81 | 76 | |
@@ -90,8 +85,7 @@ discard block |
||
90 | 85 | /** |
91 | 86 | * @return null|string |
92 | 87 | */ |
93 | - public function getQueryString() |
|
94 | - { |
|
88 | + public function getQueryString() { |
|
95 | 89 | return $this->queryString; |
96 | 90 | } |
97 | 91 | } |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\HeaderParser; |
3 | 3 | |
4 | -class ParsedHeaders |
|
5 | -{ |
|
4 | +class ParsedHeaders { |
|
6 | 5 | /** |
7 | 6 | * @var array |
8 | 7 | */ |
@@ -16,15 +15,13 @@ discard block |
||
16 | 15 | * @param array $acceptableMIMETypes |
17 | 16 | * @param $APIKey |
18 | 17 | */ |
19 | - public function __construct($contentType, array $acceptableMIMETypes, $APIKey) |
|
20 | - { |
|
18 | + public function __construct($contentType, array $acceptableMIMETypes, $APIKey) { |
|
21 | 19 | $this->contentType = $contentType; |
22 | 20 | $this->acceptableMIMETypes = $acceptableMIMETypes; |
23 | 21 | $this->APIKey = $APIKey; |
24 | 22 | } |
25 | 23 | |
26 | - public function getContentType() |
|
27 | - { |
|
24 | + public function getContentType() { |
|
28 | 25 | return $this->contentType; |
29 | 26 | } |
30 | 27 | |
@@ -33,8 +30,7 @@ discard block |
||
33 | 30 | return $this->acceptableMIMETypes; |
34 | 31 | } |
35 | 32 | |
36 | - public function getAPIKey() |
|
37 | - { |
|
33 | + public function getAPIKey() { |
|
38 | 34 | return $this->APIKey; |
39 | 35 | } |
40 | 36 | } |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\HeaderParser; |
3 | 3 | |
4 | -class DefaultHeaderParser implements HeaderParser |
|
5 | -{ |
|
4 | +class DefaultHeaderParser implements HeaderParser { |
|
6 | 5 | |
7 | 6 | private $apiKeyHeaderKey; |
8 | 7 | |
@@ -10,8 +9,7 @@ discard block |
||
10 | 9 | * DefaultHeaderParser constructor. |
11 | 10 | * @param string $apiKeyHeaderKey |
12 | 11 | */ |
13 | - public function __construct($apiKeyHeaderKey = 'x-api-key') |
|
14 | - { |
|
12 | + public function __construct($apiKeyHeaderKey = 'x-api-key') { |
|
15 | 13 | $this->apiKeyHeaderKey = $apiKeyHeaderKey; |
16 | 14 | } |
17 | 15 | |
@@ -43,8 +41,7 @@ discard block |
||
43 | 41 | return $acceptedMIMETypes; |
44 | 42 | } |
45 | 43 | |
46 | - protected function findAPIKey(array $headers) |
|
47 | - { |
|
44 | + protected function findAPIKey(array $headers) { |
|
48 | 45 | foreach ($headers as $key => $value) { |
49 | 46 | if (strtolower($key) == strtolower($this->apiKeyHeaderKey)) { |
50 | 47 | return $value; |
@@ -53,8 +50,7 @@ discard block |
||
53 | 50 | return null; |
54 | 51 | } |
55 | 52 | |
56 | - protected function getContentType(array $headers) |
|
57 | - { |
|
53 | + protected function getContentType(array $headers) { |
|
58 | 54 | foreach ($headers as $key => $value) { |
59 | 55 | if (strtolower($key) == 'content-type') { |
60 | 56 | return $value; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | { |
48 | 48 | foreach ($headers as $key => $values) { |
49 | 49 | if (strtolower($key) == strtolower($this->apiKeyHeaderKey)) { |
50 | - foreach($values as $value) { |
|
50 | + foreach ($values as $value) { |
|
51 | 51 | return $value; |
52 | 52 | } |
53 | 53 | } |