@@ -46,7 +46,7 @@ |
||
46 | 46 | $newName = $this->getFileName($key); |
47 | 47 | } |
48 | 48 | |
49 | - move_uploaded_file($this->getFileByKey($key, 'tmp_name'), $destinationPath . '/' . $newName); |
|
49 | + move_uploaded_file($this->getFileByKey($key, 'tmp_name'), $destinationPath.'/'.$newName); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function clearTemp($key) |
@@ -132,7 +132,7 @@ |
||
132 | 132 | foreach ($this->headers as $header => $values) { |
133 | 133 | $replace = true; |
134 | 134 | foreach ($values as $value) { |
135 | - $result[] = [ "$header: $value", $replace ]; |
|
135 | + $result[] = ["$header: $value", $replace]; |
|
136 | 136 | $replace = false; |
137 | 137 | } |
138 | 138 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function add($object) |
21 | 21 | { |
22 | 22 | if (!is_object($object) && !is_array($object)) { |
23 | - $object = [ $object ]; |
|
23 | + $object = [$object]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | if ($this->serializationRule !== ResponseBag::SINGLE_OBJECT) { |
@@ -186,13 +186,13 @@ |
||
186 | 186 | $servername = $this->getServerName(); |
187 | 187 | |
188 | 188 | if ($port && $this->server('SERVER_PORT' !== false)) { |
189 | - $servername .= ':' . $this->server('SERVER_PORT'); |
|
189 | + $servername .= ':'.$this->server('SERVER_PORT'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if ($protocol) { |
193 | 193 | $servername = ( |
194 | 194 | ($this->server('HTTPS') !== 'off' |
195 | - || $this->server('SERVER_PORT') == 443) ? "https://" : "http://") . $servername |
|
195 | + || $this->server('SERVER_PORT') == 443) ? "https://" : "http://").$servername |
|
196 | 196 | ; |
197 | 197 | } |
198 | 198 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | { |
69 | 69 | if (method_exists($this->handler, 'addDataTable')) { |
70 | 70 | $data = $this->handler->getDataTable(); |
71 | - $this->handler->addDataTable('Info #' . (count($data) + 1), array($name => $value)); |
|
71 | + $this->handler->addDataTable('Info #'.(count($data) + 1), array($name => $value)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -53,38 +53,38 @@ |
||
53 | 53 | |
54 | 54 | // Processing |
55 | 55 | switch ($routeInfo[0]) { |
56 | - case Dispatcher::NOT_FOUND: |
|
57 | - if ($this->tryDeliveryPhysicalFile() === false) { |
|
58 | - $this->prepareToOutput(); |
|
59 | - throw new Error404Exception("Route '$uri' not found"); |
|
60 | - } |
|
61 | - return true; |
|
62 | - |
|
63 | - case Dispatcher::METHOD_NOT_ALLOWED: |
|
56 | + case Dispatcher::NOT_FOUND: |
|
57 | + if ($this->tryDeliveryPhysicalFile() === false) { |
|
64 | 58 | $this->prepareToOutput(); |
65 | - throw new Error405Exception('Method not allowed'); |
|
59 | + throw new Error404Exception("Route '$uri' not found"); |
|
60 | + } |
|
61 | + return true; |
|
62 | + |
|
63 | + case Dispatcher::METHOD_NOT_ALLOWED: |
|
64 | + $this->prepareToOutput(); |
|
65 | + throw new Error405Exception('Method not allowed'); |
|
66 | 66 | |
67 | - case Dispatcher::FOUND: |
|
68 | - // ... 200 Process: |
|
69 | - $vars = array_merge($routeInfo[2], $queryStr); |
|
67 | + case Dispatcher::FOUND: |
|
68 | + // ... 200 Process: |
|
69 | + $vars = array_merge($routeInfo[2], $queryStr); |
|
70 | 70 | |
71 | - // Get the Selected Route |
|
72 | - $selectedRoute = $routeInfo[1]; |
|
71 | + // Get the Selected Route |
|
72 | + $selectedRoute = $routeInfo[1]; |
|
73 | 73 | |
74 | - // Default Handler for errors and |
|
75 | - $outputProcessor = $this->prepareToOutput($selectedRoute["output_processor"]); |
|
74 | + // Default Handler for errors and |
|
75 | + $outputProcessor = $this->prepareToOutput($selectedRoute["output_processor"]); |
|
76 | 76 | |
77 | - // Class |
|
78 | - $class = $selectedRoute["class"]; |
|
79 | - $request->appendVars($vars); |
|
77 | + // Class |
|
78 | + $class = $selectedRoute["class"]; |
|
79 | + $request->appendVars($vars); |
|
80 | 80 | |
81 | - // Execute the request |
|
82 | - $this->executeRequest($outputProcessor, $class, $request); |
|
81 | + // Execute the request |
|
82 | + $this->executeRequest($outputProcessor, $class, $request); |
|
83 | 83 | |
84 | - break; |
|
84 | + break; |
|
85 | 85 | |
86 | - default: |
|
87 | - throw new Error520Exception('Unknown'); |
|
86 | + default: |
|
87 | + throw new Error520Exception('Unknown'); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 |
@@ -127,7 +127,7 @@ |
||
127 | 127 | |
128 | 128 | // Process Class::Method() |
129 | 129 | $function = $class[1]; |
130 | - $class = $class[0]; |
|
130 | + $class = $class[0]; |
|
131 | 131 | if (!class_exists($class)) { |
132 | 132 | throw new ClassNotFoundException("Class '$class' defined in the route is not found"); |
133 | 133 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | new RoutePattern( |
97 | 97 | $route->getMethod(), |
98 | 98 | $route->getPattern(), |
99 | - function () use ($route) { |
|
99 | + function() use ($route) { |
|
100 | 100 | return new MockOutputProcessor($route->getOutputProcessor()); |
101 | 101 | }, |
102 | 102 | $class, |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function getDispatcher() |
48 | 48 | { |
49 | 49 | // Generic Dispatcher for RestServer |
50 | - return simpleDispatcher(function (RouteCollector $r) { |
|
50 | + return simpleDispatcher(function(RouteCollector $r) { |
|
51 | 51 | |
52 | 52 | foreach ($this->getRoutes() as $route) { |
53 | 53 | $r->addRoute( |
@@ -125,8 +125,9 @@ |
||
125 | 125 | |
126 | 126 | // loop data blocks |
127 | 127 | foreach ($blocks as $id => $block) { |
128 | - if (empty($block)) |
|
129 | - continue; |
|
128 | + if (empty($block)) { |
|
129 | + continue; |
|
130 | + } |
|
130 | 131 | |
131 | 132 | $name = []; |
132 | 133 | preg_match('/\bname=\"([^\"]*)\"\s*;/s', $block, $name); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @var Request |
12 | 12 | */ |
13 | - protected $psrRequest ; |
|
13 | + protected $psrRequest; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->server["REMOTE_ADDR"] = "127.0.0.1"; |
54 | 54 | $this->server["REMOTE_PORT"] = rand(1000, 60000); |
55 | 55 | $this->server["SERVER_SOFTWARE"] = "Mock"; |
56 | - $this->server["SERVER_PROTOCOL"] = "HTTP/" . $this->psrRequest->getProtocolVersion(); |
|
56 | + $this->server["SERVER_PROTOCOL"] = "HTTP/".$this->psrRequest->getProtocolVersion(); |
|
57 | 57 | $this->server["SERVER_NAME"] = $this->psrRequest->getUri()->getHost(); |
58 | 58 | $this->server["SERVER_PORT"] = $this->psrRequest->getUri()->getPort(); |
59 | 59 | $this->server["REQUEST_URI"] = $this->psrRequest->getRequestTarget(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // Headers and Cookies |
71 | 71 | $this->cookie = []; |
72 | 72 | foreach ($this->psrRequest->getHeaders() as $key => $value) { |
73 | - $this->server["HTTP_" . strtoupper($key)] = $this->psrRequest->getHeaderLine($key); |
|
73 | + $this->server["HTTP_".strtoupper($key)] = $this->psrRequest->getHeaderLine($key); |
|
74 | 74 | |
75 | 75 | if ($key == "Cookie") { |
76 | 76 | parse_str(preg_replace("/;\s*/", "&", $this->psrRequest->getHeaderLine($key)), $this->cookie); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'name' => $filename[1], |
158 | 158 | 'type' => (empty($contentType) ? "" : trim($contentType[1])), |
159 | 159 | 'size' => strlen($content), |
160 | - 'tmp_name' => sys_get_temp_dir() . "/" . $filename[1], |
|
160 | + 'tmp_name' => sys_get_temp_dir()."/".$filename[1], |
|
161 | 161 | 'error' => null |
162 | 162 | ]; |
163 | 163 | file_put_contents($strut["tmp_name"], $content); |