@@ -40,8 +40,8 @@ |
||
40 | 40 | public function getDetailedErrorHandler(); |
41 | 41 | |
42 | 42 | /** |
43 | - * @return Handler |
|
44 | - */ |
|
43 | + * @return Handler |
|
44 | + */ |
|
45 | 45 | public function getErrorHandler(); |
46 | 46 | |
47 | 47 | /** |
@@ -20,8 +20,8 @@ |
||
20 | 20 | |
21 | 21 | protected function writeHeader(HttpResponse $response) |
22 | 22 | { |
23 | - echo "HTTP/1.1 " . $response->getResponseCode() . "\r\n"; |
|
24 | - echo "Content-Type: " . $this->getContentType() . "\r\n"; |
|
23 | + echo "HTTP/1.1 ".$response->getResponseCode()."\r\n"; |
|
24 | + echo "Content-Type: ".$this->getContentType()."\r\n"; |
|
25 | 25 | |
26 | 26 | foreach ($response->getHeaders() as $header => $value) { |
27 | 27 | if (is_array($value)) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (defined("RESTSERVER_TEST")) { |
63 | 63 | return; |
64 | 64 | } |
65 | - header("Content-Type: " . $this->contentType); |
|
65 | + header("Content-Type: ".$this->contentType); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getContentType() |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | foreach ($response->getHeaders() as $header => $value) { |
76 | 76 | if (is_array($value)) { |
77 | - header("$header: " . array_shift($value), true); |
|
77 | + header("$header: ".array_shift($value), true); |
|
78 | 78 | foreach ($value as $headerValue) { |
79 | 79 | header("$header: $headerValue", false); |
80 | 80 | } |
@@ -74,42 +74,42 @@ |
||
74 | 74 | |
75 | 75 | // Processing |
76 | 76 | switch ($routeInfo[0]) { |
77 | - case Dispatcher::NOT_FOUND: |
|
78 | - if ($this->tryDeliveryPhysicalFile() === false) { |
|
79 | - $this->prepareToOutput(); |
|
80 | - throw new Error404Exception("Route '$uri' not found"); |
|
81 | - } |
|
82 | - return true; |
|
77 | + case Dispatcher::NOT_FOUND: |
|
78 | + if ($this->tryDeliveryPhysicalFile() === false) { |
|
79 | + $this->prepareToOutput(); |
|
80 | + throw new Error404Exception("Route '$uri' not found"); |
|
81 | + } |
|
82 | + return true; |
|
83 | 83 | |
84 | - case Dispatcher::METHOD_NOT_ALLOWED: |
|
85 | - $outputProcessor = $this->prepareToOutput(); |
|
86 | - if (strtoupper($httpMethod) == "OPTIONS" && !empty($this->corsOrigins)) { |
|
87 | - $this->executeRequest($outputProcessor, function () {}, $request); |
|
88 | - return; |
|
89 | - } |
|
90 | - throw new Error405Exception('Method not allowed'); |
|
84 | + case Dispatcher::METHOD_NOT_ALLOWED: |
|
85 | + $outputProcessor = $this->prepareToOutput(); |
|
86 | + if (strtoupper($httpMethod) == "OPTIONS" && !empty($this->corsOrigins)) { |
|
87 | + $this->executeRequest($outputProcessor, function () {}, $request); |
|
88 | + return; |
|
89 | + } |
|
90 | + throw new Error405Exception('Method not allowed'); |
|
91 | 91 | |
92 | - case Dispatcher::FOUND: |
|
93 | - // ... 200 Process: |
|
94 | - $vars = array_merge($routeInfo[2], $queryStr); |
|
92 | + case Dispatcher::FOUND: |
|
93 | + // ... 200 Process: |
|
94 | + $vars = array_merge($routeInfo[2], $queryStr); |
|
95 | 95 | |
96 | - // Get the Selected Route |
|
97 | - $selectedRoute = $routeInfo[1]; |
|
96 | + // Get the Selected Route |
|
97 | + $selectedRoute = $routeInfo[1]; |
|
98 | 98 | |
99 | - // Default Handler for errors and |
|
100 | - $outputProcessor = $this->prepareToOutput($selectedRoute["output_processor"]); |
|
99 | + // Default Handler for errors and |
|
100 | + $outputProcessor = $this->prepareToOutput($selectedRoute["output_processor"]); |
|
101 | 101 | |
102 | - // Class |
|
103 | - $class = $selectedRoute["class"]; |
|
104 | - $request->appendVars($vars); |
|
102 | + // Class |
|
103 | + $class = $selectedRoute["class"]; |
|
104 | + $request->appendVars($vars); |
|
105 | 105 | |
106 | - // Execute the request |
|
107 | - $this->executeRequest($outputProcessor, $class, $request); |
|
106 | + // Execute the request |
|
107 | + $this->executeRequest($outputProcessor, $class, $request); |
|
108 | 108 | |
109 | - break; |
|
109 | + break; |
|
110 | 110 | |
111 | - default: |
|
112 | - throw new Error520Exception('Unknown'); |
|
111 | + default: |
|
112 | + throw new Error520Exception('Unknown'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | protected $useErrorHandler = true; |
24 | 24 | protected $detailedErrorHandler = false; |
25 | 25 | protected $corsOrigins = []; |
26 | - protected $corsMethods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
26 | + protected $corsMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
27 | 27 | protected $corsHeaders = [ |
28 | 28 | 'Authorization', |
29 | 29 | 'Content-Type', |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | case Dispatcher::METHOD_NOT_ALLOWED: |
85 | 85 | $outputProcessor = $this->prepareToOutput(); |
86 | 86 | if (strtoupper($httpMethod) == "OPTIONS" && !empty($this->corsOrigins)) { |
87 | - $this->executeRequest($outputProcessor, function () {}, $request); |
|
87 | + $this->executeRequest($outputProcessor, function() {}, $request); |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | throw new Error405Exception('Method not allowed'); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | if (preg_match("~^.*//$origin$~", $request->server('HTTP_ORIGIN'))) { |
157 | 157 | $response->addHeader("Access-Control-Allow-Origin", $request->server('HTTP_ORIGIN')); |
158 | 158 | $response->addHeader('Access-Control-Allow-Credentials', 'true'); |
159 | - $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
159 | + $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
160 | 160 | |
161 | 161 | // Access-Control headers are received during OPTIONS requests |
162 | 162 | if ($request->server('REQUEST_METHOD') == 'OPTIONS') { |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | // Process Class::Method() |
182 | 182 | $function = $class[1]; |
183 | - $class = $class[0]; |
|
183 | + $class = $class[0]; |
|
184 | 184 | if (!class_exists($class)) { |
185 | 185 | throw new ClassNotFoundException("Class '$class' defined in the route is not found"); |
186 | 186 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | throw new InvalidArgumentException("Default processor needs to class name of an OutputProcessor"); |
366 | 366 | } |
367 | 367 | if (!is_subclass_of($processor, BaseOutputProcessor::class)) { |
368 | - throw new InvalidArgumentException("Needs to be a class of " . BaseOutputProcessor::class); |
|
368 | + throw new InvalidArgumentException("Needs to be a class of ".BaseOutputProcessor::class); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 |