@@ -6,7 +6,6 @@ |
||
6 | 6 | * Class InvalidRequestURLException |
7 | 7 | * @package LunixREST\RequestFactory\URLParser\RegexURLParser\Exceptions |
8 | 8 | */ |
9 | -class InvalidRegexPatternException extends \Exception |
|
10 | -{ |
|
9 | +class InvalidRegexPatternException extends \Exception { |
|
11 | 10 | |
12 | 11 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * Interface URLParser |
10 | 10 | * @package LunixREST\RequestFactory\URLParser |
11 | 11 | */ |
12 | -interface URLParser |
|
13 | -{ |
|
12 | +interface URLParser { |
|
14 | 13 | /** |
15 | 14 | * Parses API request data out of a url |
16 | 15 | * @param UriInterface $uri |
@@ -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 | } |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | * Class DefaultHeaderParser |
7 | 7 | * @package LunixREST\RequestFactory\HeaderParser |
8 | 8 | */ |
9 | -class DefaultHeaderParser implements HeaderParser |
|
10 | -{ |
|
9 | +class DefaultHeaderParser implements HeaderParser { |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * @var string |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | * DefaultHeaderParser constructor. |
19 | 18 | * @param string $apiKeyHeaderKey |
20 | 19 | */ |
21 | - public function __construct($apiKeyHeaderKey = 'x-api-key') |
|
22 | - { |
|
20 | + public function __construct($apiKeyHeaderKey = 'x-api-key') { |
|
23 | 21 | $this->apiKeyHeaderKey = $apiKeyHeaderKey; |
24 | 22 | } |
25 | 23 | |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | * @param array $headers |
64 | 62 | * @return null |
65 | 63 | */ |
66 | - protected function findAPIKey(array $headers) |
|
67 | - { |
|
64 | + protected function findAPIKey(array $headers) { |
|
68 | 65 | foreach ($headers as $key => $values) { |
69 | 66 | if (strtolower($key) == strtolower($this->apiKeyHeaderKey)) { |
70 | 67 | foreach($values as $value) { |
@@ -79,8 +76,7 @@ discard block |
||
79 | 76 | * @param array $headers |
80 | 77 | * @return null |
81 | 78 | */ |
82 | - protected function getContentType(array $headers) |
|
83 | - { |
|
79 | + protected function getContentType(array $headers) { |
|
84 | 80 | foreach ($headers as $key => $values) { |
85 | 81 | if (strtolower($key) == 'content-type') { |
86 | 82 | foreach ($values as $value) { |
@@ -6,8 +6,7 @@ |
||
6 | 6 | * Interface HeaderParser |
7 | 7 | * @package LunixREST\RequestFactory\HeaderParser |
8 | 8 | */ |
9 | -interface HeaderParser |
|
10 | -{ |
|
9 | +interface HeaderParser { |
|
11 | 10 | /** |
12 | 11 | * @param array $headers |
13 | 12 | * @return ParsedHeaders |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | * Class ParsedHeaders |
7 | 7 | * @package LunixREST\RequestFactory\HeaderParser |
8 | 8 | */ |
9 | -class ParsedHeaders |
|
10 | -{ |
|
9 | +class ParsedHeaders { |
|
11 | 10 | /** |
12 | 11 | * @var array |
13 | 12 | */ |
@@ -27,8 +26,7 @@ discard block |
||
27 | 26 | * @param array $acceptableMIMETypes |
28 | 27 | * @param $APIKey |
29 | 28 | */ |
30 | - public function __construct($contentType, array $acceptableMIMETypes, $APIKey) |
|
31 | - { |
|
29 | + public function __construct($contentType, array $acceptableMIMETypes, $APIKey) { |
|
32 | 30 | $this->contentType = $contentType; |
33 | 31 | $this->acceptableMIMETypes = $acceptableMIMETypes; |
34 | 32 | $this->APIKey = $APIKey; |
@@ -37,8 +35,7 @@ discard block |
||
37 | 35 | /** |
38 | 36 | * @return mixed |
39 | 37 | */ |
40 | - public function getContentType() |
|
41 | - { |
|
38 | + public function getContentType() { |
|
42 | 39 | return $this->contentType; |
43 | 40 | } |
44 | 41 | |
@@ -53,8 +50,7 @@ discard block |
||
53 | 50 | /** |
54 | 51 | * @return mixed |
55 | 52 | */ |
56 | - public function getAPIKey() |
|
57 | - { |
|
53 | + public function getAPIKey() { |
|
58 | 54 | return $this->APIKey; |
59 | 55 | } |
60 | 56 | } |
@@ -9,10 +9,8 @@ |
||
9 | 9 | * Class BasicRequestFactory |
10 | 10 | * @package LunixREST\RequestFactory |
11 | 11 | */ |
12 | -class DefaultRequestFactory extends GenericRequestFactory |
|
13 | -{ |
|
14 | - public function __construct(URLParser $URLParser) |
|
15 | - { |
|
12 | +class DefaultRequestFactory extends GenericRequestFactory { |
|
13 | + public function __construct(URLParser $URLParser) { |
|
16 | 14 | parent::__construct($URLParser, new DefaultHeaderParser()); |
17 | 15 | } |
18 | 16 | } |
@@ -48,12 +48,12 @@ |
||
48 | 48 | $parsedHeaders = $this->headerParser->parse($serverRequest->getHeaders()); |
49 | 49 | |
50 | 50 | $urlQueryData = []; |
51 | - if($urlQueryString = $parsedURL->getQueryString()) { |
|
51 | + if ($urlQueryString = $parsedURL->getQueryString()) { |
|
52 | 52 | parse_str($urlQueryString, $urlQueryData); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $apiKey = $parsedURL->getAPIKey(); |
56 | - if($apiKey === null) { |
|
56 | + if ($apiKey === null) { |
|
57 | 57 | $apiKey = $parsedHeaders->getAPIKey(); |
58 | 58 | } |
59 | 59 |
@@ -28,8 +28,7 @@ |
||
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 | } |
@@ -10,8 +10,7 @@ |
||
10 | 10 | * Class JSONHTTPServer |
11 | 11 | * @package LunixREST |
12 | 12 | */ |
13 | -class JSONHTTPServer extends HTTPServer |
|
14 | -{ |
|
13 | +class JSONHTTPServer extends HTTPServer { |
|
15 | 14 | /** |
16 | 15 | * @param ServerRequestInterface $serverRequest |
17 | 16 | * @param ResponseInterface $response |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | $body = $response->getBody(); |
93 | - while(!$body->eof()) { |
|
93 | + while (!$body->eof()) { |
|
94 | 94 | echo $body->read(1024); |
95 | 95 | } |
96 | 96 | } |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | * Class HTTPServer |
27 | 27 | * @package LunixREST |
28 | 28 | */ |
29 | -class HTTPServer |
|
30 | -{ |
|
29 | +class HTTPServer { |
|
31 | 30 | use LoggerAwareTrait; |
32 | 31 | |
33 | 32 | /** |
@@ -45,8 +44,7 @@ discard block |
||
45 | 44 | * @param RequestFactory $requestFactory |
46 | 45 | * @param LoggerInterface $logger |
47 | 46 | */ |
48 | - public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) |
|
49 | - { |
|
47 | + public function __construct(Server $server, RequestFactory $requestFactory, LoggerInterface $logger) { |
|
50 | 48 | $this->server = $server; |
51 | 49 | $this->requestFactory = $requestFactory; |
52 | 50 | $this->logger = $logger; |
@@ -82,8 +80,7 @@ discard block |
||
82 | 80 | * @param ResponseInterface $response |
83 | 81 | * @return ResponseInterface |
84 | 82 | */ |
85 | - protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) |
|
86 | - { |
|
83 | + protected function handleAPIRequest(APIRequest $APIRequest, ResponseInterface $response) { |
|
87 | 84 | try { |
88 | 85 | $APIResponse = $this->server->handleRequest($APIRequest); |
89 | 86 | |
@@ -120,8 +117,7 @@ discard block |
||
120 | 117 | * Dumps a PSR-7 ResponseInterface to the SAPI. |
121 | 118 | * @param ResponseInterface $response |
122 | 119 | */ |
123 | - public static function dumpResponse(ResponseInterface $response) |
|
124 | - { |
|
120 | + public static function dumpResponse(ResponseInterface $response) { |
|
125 | 121 | $statusLine = sprintf( |
126 | 122 | "HTTP/%s %d %s", |
127 | 123 | $response->getProtocolVersion(), |