@@ -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; |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\HeaderParser; |
3 | 3 | |
4 | -interface HeaderParser |
|
5 | -{ |
|
4 | +interface HeaderParser { |
|
6 | 5 | public function parse(array $headers): ParsedHeaders; |
7 | 6 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | use LunixREST\Request\BodyParser\BodyParser; |
5 | 5 | use LunixREST\Request\BodyParser\BodyParserFactory\Exceptions\UnknownContentTypeException; |
6 | 6 | |
7 | -interface BodyParserFactory |
|
8 | -{ |
|
7 | +interface BodyParserFactory { |
|
9 | 8 | /** |
10 | 9 | * Parses API request data out of a url |
11 | 10 | * @param string $contentType |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\BodyParser\BodyParserFactory\Exceptions; |
3 | 3 | |
4 | -class UnknownContentTypeException extends \Exception |
|
5 | -{ |
|
4 | +class UnknownContentTypeException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | * Class RegisteredBodyParserFactory |
10 | 10 | * @package LunixREST\Request\BodyParser |
11 | 11 | */ |
12 | -class RegisteredBodyParserFactory implements BodyParserFactory |
|
13 | -{ |
|
12 | +class RegisteredBodyParserFactory implements BodyParserFactory { |
|
14 | 13 | |
15 | 14 | protected $contentTypeToParserMap; |
16 | 15 | |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | * RegisteredBodyParserFactory constructor. |
19 | 18 | * @param BodyParser[] $mappings keyed by content type |
20 | 19 | */ |
21 | - public function __construct($mappings = []) |
|
22 | - { |
|
20 | + public function __construct($mappings = []) { |
|
23 | 21 | foreach ($mappings as $contentType => $bodyParser) { |
24 | 22 | $this->add($contentType, $bodyParser); |
25 | 23 | } |
@@ -29,8 +27,7 @@ discard block |
||
29 | 27 | * @param $contentType |
30 | 28 | * @param BodyParser $bodyParser |
31 | 29 | */ |
32 | - public function add($contentType, BodyParser $bodyParser) |
|
33 | - { |
|
30 | + public function add($contentType, BodyParser $bodyParser) { |
|
34 | 31 | $this->contentTypeToParserMap[strtolower($contentType)] = $bodyParser; |
35 | 32 | } |
36 | 33 |
@@ -10,21 +10,18 @@ |
||
10 | 10 | * Class DefaultBodyParserFactory |
11 | 11 | * @package LunixREST\Request\BodyParser |
12 | 12 | */ |
13 | -class DefaultBodyParserFactory implements BodyParserFactory |
|
14 | -{ |
|
13 | +class DefaultBodyParserFactory implements BodyParserFactory { |
|
15 | 14 | |
16 | 15 | protected $registeredBodyParserFactory; |
17 | 16 | |
18 | - public function __construct() |
|
19 | - { |
|
17 | + public function __construct() { |
|
20 | 18 | $this->registeredBodyParserFactory = new RegisteredBodyParserFactory([ |
21 | 19 | 'application/json' => new JSONBodyParser(), |
22 | 20 | 'application/x-www-form-urlencoded' => new URLEncodedBodyParser() |
23 | 21 | ]); |
24 | 22 | } |
25 | 23 | |
26 | - public function add($contentType, BodyParser $bodyParser) |
|
27 | - { |
|
24 | + public function add($contentType, BodyParser $bodyParser) { |
|
28 | 25 | $this->registeredBodyParserFactory->add($contentType, $bodyParser); |
29 | 26 | } |
30 | 27 |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Request\BodyParser\Exceptions; |
3 | 3 | |
4 | -class InvalidRequestDataException extends \Exception |
|
5 | -{ |
|
4 | +class InvalidRequestDataException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |