@@ -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 | } |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -5,8 +5,7 @@ |
||
5 | 5 | use LunixREST\Request\RequestData\JSONRequestData; |
6 | 6 | use LunixREST\Request\RequestData\RequestData; |
7 | 7 | |
8 | -class JSONBodyParser implements BodyParser |
|
9 | -{ |
|
8 | +class JSONBodyParser implements BodyParser { |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * Parses API request data out of a json string |
@@ -101,7 +101,7 @@ |
||
101 | 101 | */ |
102 | 102 | public function getMethod() |
103 | 103 | { |
104 | - return $this->method . ($this->instance ? '' : 'All'); |
|
104 | + return $this->method.($this->instance ? '' : 'All'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | * Class Request |
9 | 9 | * @package LunixREST\Request |
10 | 10 | */ |
11 | -class Request |
|
12 | -{ |
|
11 | +class Request { |
|
13 | 12 | /** |
14 | 13 | * @var string |
15 | 14 | */ |
@@ -91,48 +90,42 @@ discard block |
||
91 | 90 | /** |
92 | 91 | * @return string |
93 | 92 | */ |
94 | - public function getIp() |
|
95 | - { |
|
93 | + public function getIp() { |
|
96 | 94 | return $this->ip; |
97 | 95 | } |
98 | 96 | |
99 | 97 | /** |
100 | 98 | * @return string |
101 | 99 | */ |
102 | - public function getMethod() |
|
103 | - { |
|
100 | + public function getMethod() { |
|
104 | 101 | return $this->method . ($this->instance ? '' : 'All'); |
105 | 102 | } |
106 | 103 | |
107 | 104 | /** |
108 | 105 | * @return array |
109 | 106 | */ |
110 | - public function getHeaders() |
|
111 | - { |
|
107 | + public function getHeaders() { |
|
112 | 108 | return $this->headers; |
113 | 109 | } |
114 | 110 | |
115 | 111 | /** |
116 | 112 | * @return string |
117 | 113 | */ |
118 | - public function getVersion() |
|
119 | - { |
|
114 | + public function getVersion() { |
|
120 | 115 | return $this->version; |
121 | 116 | } |
122 | 117 | |
123 | 118 | /** |
124 | 119 | * @return string |
125 | 120 | */ |
126 | - public function getApiKey() |
|
127 | - { |
|
121 | + public function getApiKey() { |
|
128 | 122 | return $this->apiKey; |
129 | 123 | } |
130 | 124 | |
131 | 125 | /** |
132 | 126 | * @return string |
133 | 127 | */ |
134 | - public function getEndpoint() |
|
135 | - { |
|
128 | + public function getEndpoint() { |
|
136 | 129 | return $this->endpoint; |
137 | 130 | } |
138 | 131 | |
@@ -147,8 +140,7 @@ discard block |
||
147 | 140 | /** |
148 | 141 | * @return string |
149 | 142 | */ |
150 | - public function getInstance() |
|
151 | - { |
|
143 | + public function getInstance() { |
|
152 | 144 | return $this->instance; |
153 | 145 | } |
154 | 146 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function getEndpoint(string $name, string $version): Endpoint |
27 | 27 | { |
28 | - $className = $this->buildVersionedEndpointNamespace($version) . $name; |
|
28 | + $className = $this->buildVersionedEndpointNamespace($version).$name; |
|
29 | 29 | if (!class_exists($className)) { |
30 | 30 | throw new UnknownEndpointException("Could not find $className"); |
31 | 31 | } |
@@ -54,6 +54,6 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function buildVersionedEndpointNamespace(string $version): string |
56 | 56 | { |
57 | - return $this->endpointNamespace . '\v' . str_replace('.', '_', $version) . '\\'; |
|
57 | + return $this->endpointNamespace.'\v'.str_replace('.', '_', $version).'\\'; |
|
58 | 58 | } |
59 | 59 | } |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use LunixREST\Endpoint\Exceptions\UnknownEndpointException; |
5 | 5 | |
6 | -class NamespaceEndpointFactory implements EndpointFactory |
|
7 | -{ |
|
6 | +class NamespaceEndpointFactory implements EndpointFactory { |
|
8 | 7 | |
9 | 8 | protected $endpointNamespace; |
10 | 9 | |
@@ -12,8 +11,7 @@ discard block |
||
12 | 11 | * NamespaceEndpointFactory constructor. |
13 | 12 | * @param string $endpointNamespace |
14 | 13 | */ |
15 | - public function __construct(string $endpointNamespace) |
|
16 | - { |
|
14 | + public function __construct(string $endpointNamespace) { |
|
17 | 15 | $this->endpointNamespace = $endpointNamespace; |
18 | 16 | } |
19 | 17 |
@@ -3,8 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use LunixREST\Endpoint\Exceptions\UnknownEndpointException; |
5 | 5 | |
6 | -interface EndpointFactory |
|
7 | -{ |
|
6 | +interface EndpointFactory { |
|
8 | 7 | /** |
9 | 8 | * @param string $name |
10 | 9 | * @param string $version |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace LunixREST\Endpoint\Exceptions; |
3 | 3 | |
4 | -class UnknownEndpointException extends \Exception |
|
5 | -{ |
|
4 | +class UnknownEndpointException extends \Exception { |
|
6 | 5 | |
7 | 6 | } |