@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $refClass = new \ReflectionClass($ex); |
| 20 | 20 | |
| 21 | - $title = str_replace("Exception", "", $refClass->getShortName()); |
|
| 21 | + $title = str_replace("Exception", "", $refClass->getShortName()); |
|
| 22 | 22 | $title = preg_replace("/([a-z0-9])([A-Z])/", "$1 $2", $title); |
| 23 | 23 | return preg_replace("/([a-z])(\d)/", "$1 $2", $title); |
| 24 | 24 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if (!is_object($object) && !is_array($object)) { |
| 29 | - $object = [ $object ]; |
|
| 29 | + $object = [$object]; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ($this->serializationRule !== ResponseBag::SINGLE_OBJECT && $this->serializationRule !== ResponseBag::RAW) { |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | foreach ($response->getHeaders() as $header => $value) { |
| 85 | 85 | if (is_array($value)) { |
| 86 | - $this->writer->header("$header: " . array_shift($value), true); |
|
| 86 | + $this->writer->header("$header: ".array_shift($value), true); |
|
| 87 | 87 | foreach ($value as $headerValue) { |
| 88 | 88 | $this->writer->header("$header: $headerValue", false); |
| 89 | 89 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | // Process Class::Method() |
| 204 | 204 | $function = $class[1]; |
| 205 | - $class = $class[0]; |
|
| 205 | + $class = $class[0]; |
|
| 206 | 206 | if (!class_exists($class)) { |
| 207 | 207 | throw new ClassNotFoundException("Class '$class' defined in the route is not found"); |
| 208 | 208 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | throw new InvalidArgumentException("Default processor needs to class name of an OutputProcessor"); |
| 281 | 281 | } |
| 282 | 282 | if (!is_subclass_of($processor, BaseOutputProcessor::class)) { |
| 283 | - throw new InvalidArgumentException("Needs to be a class of " . BaseOutputProcessor::class); |
|
| 283 | + throw new InvalidArgumentException("Needs to be a class of ".BaseOutputProcessor::class); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | const CORS_OPTIONS = 'CORS_OPTIONS'; |
| 16 | 16 | |
| 17 | 17 | protected $corsOrigins = ['.*']; |
| 18 | - protected $corsMethods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 18 | + protected $corsMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 19 | 19 | protected $corsHeaders = [ |
| 20 | 20 | 'Authorization', |
| 21 | 21 | 'Content-Type', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if (preg_match("~^.*//$origin$~", $request->server('HTTP_ORIGIN'))) { |
| 75 | 75 | $response->addHeader("Access-Control-Allow-Origin", $request->server('HTTP_ORIGIN')); |
| 76 | 76 | $response->addHeader('Access-Control-Allow-Credentials', 'true'); |
| 77 | - $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 77 | + $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 78 | 78 | |
| 79 | 79 | // Access-Control headers are received during OPTIONS requests |
| 80 | 80 | if ($request->server('REQUEST_METHOD') == 'OPTIONS') { |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | |
| 18 | 18 | if ($replace) { |
| 19 | 19 | $headerParts = explode(':', $header); |
| 20 | - for ($i=0; $i<count($this->headerList); $i++) { |
|
| 21 | - if (preg_match("~^" . $headerParts[0] . "~", $this->headerList[$i]) === 1) { |
|
| 20 | + for ($i = 0; $i < count($this->headerList); $i++) { |
|
| 21 | + if (preg_match("~^".$headerParts[0]."~", $this->headerList[$i]) === 1) { |
|
| 22 | 22 | $this->headerList[$i] = $header; |
| 23 | 23 | return; |
| 24 | 24 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function withOutputProcessorForRoute($method, $path, $processor) |
| 68 | 68 | { |
| 69 | - $this->overrideOutputProcessor[strtoupper($method) . " " . $path] = $processor; |
|
| 69 | + $this->overrideOutputProcessor[strtoupper($method)." ".$path] = $processor; |
|
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | ); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $outputProcessor = $this->getMethodOutputProcessor($method, $basePath. $path, $properties); |
|
| 133 | + $outputProcessor = $this->getMethodOutputProcessor($method, $basePath.$path, $properties); |
|
| 134 | 134 | |
| 135 | - $routes[] = (new Route(strtoupper($method), $basePath . $path)) |
|
| 135 | + $routes[] = (new Route(strtoupper($method), $basePath.$path)) |
|
| 136 | 136 | ->withOutputProcessor($outputProcessor) |
| 137 | 137 | ->withClass($parts[0], $parts[1]); |
| 138 | 138 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | protected function sortPaths($pathList) |
| 145 | 145 | { |
| 146 | - usort($pathList, function ($left, $right) { |
|
| 146 | + usort($pathList, function($left, $right) { |
|
| 147 | 147 | if (strpos($left, '{') === false && strpos($right, '{') !== false) { |
| 148 | 148 | return -16384; |
| 149 | 149 | } |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | protected function getMethodOutputProcessor($method, $path, $properties) |
| 173 | 173 | { |
| 174 | - $key = strtoupper($method) . " " . $path; |
|
| 174 | + $key = strtoupper($method)." ".$path; |
|
| 175 | 175 | if (isset($this->overrideOutputProcessor[$key])) { |
| 176 | 176 | return $this->overrideOutputProcessor[$key]; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $produces = null; |
| 180 | 180 | if (isset($properties['produces'])) { |
| 181 | - $produces = (array) $properties['produces']; |
|
| 181 | + $produces = (array)$properties['produces']; |
|
| 182 | 182 | } |
| 183 | 183 | if (empty($produces) && isset($properties["responses"]["200"]["content"])) { |
| 184 | 184 | $produces = array_keys($properties["responses"]["200"]["content"]); |