@@ -184,25 +184,25 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | public function import($data) { |
| 186 | 186 | |
| 187 | - if (isset($data->headers)) $this->setHeaders($data->headers); |
|
| 188 | - if (isset($data->status)) $this->setStatus($data->status); |
|
| 189 | - if (isset($data->content)) $this->setContent($data->content); |
|
| 190 | - if (isset($data->location)) $this->setLocation($data->location); |
|
| 187 | + if ( isset($data->headers) ) $this->setHeaders($data->headers); |
|
| 188 | + if ( isset($data->status) ) $this->setStatus($data->status); |
|
| 189 | + if ( isset($data->content) ) $this->setContent($data->content); |
|
| 190 | + if ( isset($data->location) ) $this->setLocation($data->location); |
|
| 191 | 191 | |
| 192 | - if (isset($data->cookies) && is_array($data->cookies)) { |
|
| 192 | + if ( isset($data->cookies) && is_array($data->cookies) ) { |
|
| 193 | 193 | $cookies = $this->getCookies(); |
| 194 | - foreach ($data->cookies as $name => $cookie) $cookies->add($cookie); |
|
| 194 | + foreach ( $data->cookies as $name => $cookie ) $cookies->add($cookie); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function consolidate(Request $request, Route $route=null) { |
|
| 199 | + public function consolidate(Request $request, Route $route = null) { |
|
| 200 | 200 | |
| 201 | 201 | $status = $this->getStatus()->get(); |
| 202 | 202 | $preprocessor = $this->getPreprocessor()->get($status); |
| 203 | 203 | $preprocessor->consolidate($this); |
| 204 | 204 | |
| 205 | - if ($route != null) { |
|
| 205 | + if ( $route != null ) { |
|
| 206 | 206 | $this->setClientCache($request, $route); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -210,19 +210,19 @@ discard block |
||
| 210 | 210 | $content = $this->getContent(); |
| 211 | 211 | $headers = $this->getHeaders(); |
| 212 | 212 | |
| 213 | - if ((string)$request->getMethod() == 'HEAD' && !in_array($status, self::$no_content_statuses)) { |
|
| 213 | + if ( (string)$request->getMethod() == 'HEAD' && !in_array($status, self::$no_content_statuses) ) { |
|
| 214 | 214 | $length = $content->length(); |
| 215 | 215 | $content->set(null); |
| 216 | - if ($length) { |
|
| 216 | + if ( $length ) { |
|
| 217 | 217 | $headers->set('Content-Length', $length); |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ($headers->get('Transfer-Encoding') != null) { |
|
| 221 | + if ( $headers->get('Transfer-Encoding') != null ) { |
|
| 222 | 222 | $headers->delete('Content-Length'); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ((string)$request->getVersion() == '1.0' && false !== strpos($headers->get('Cache-Control'), 'no-cache')) { |
|
| 225 | + if ( (string)$request->getVersion() == '1.0' && false !== strpos($headers->get('Cache-Control'), 'no-cache') ) { |
|
| 226 | 226 | $headers->set('pragma', 'no-cache'); |
| 227 | 227 | $headers->set('expires', -1); |
| 228 | 228 | } |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | ) { |
| 244 | 244 | |
| 245 | 245 | $headers = $this->getHeaders(); |
| 246 | - $timestamp = (int) $this->getTime()->format('U')+$ttl; |
|
| 246 | + $timestamp = (int)$this->getTime()->format('U')+$ttl; |
|
| 247 | 247 | |
| 248 | - if ($ttl > 0) { |
|
| 248 | + if ( $ttl > 0 ) { |
|
| 249 | 249 | |
| 250 | 250 | $headers->set("Cache-Control", "max-age=".$ttl.", must-revalidate"); |
| 251 | 251 | $headers->set("Expires", gmdate("D, d M Y H:i:s", $timestamp)." GMT"); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | $location = $response->getLocation()->get(); |
| 31 | 31 | |
| 32 | - if ($location != null) { |
|
| 32 | + if ( $location != null ) { |
|
| 33 | 33 | $response->getHeaders() |
| 34 | 34 | ->set("Location", $location); |
| 35 | 35 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | // @NOTE Allow Header should be provided by DispatcherException |
| 32 | 32 | $allow = $response->getHeaders()->get('Allow'); |
| 33 | 33 | |
| 34 | - if (empty($allow)) { |
|
| 34 | + if ( empty($allow) ) { |
|
| 35 | 35 | throw new Exception("Missing Allow header"); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $type = $response->getContent()->type(); |
| 34 | 34 | $charset = $response->getContent()->charset(); |
| 35 | 35 | |
| 36 | - if (empty($charset)) { |
|
| 36 | + if ( empty($charset) ) { |
|
| 37 | 37 | $response->getHeaders()->set("Content-type", strtolower($type)); |
| 38 | 38 | } else { |
| 39 | 39 | $response->getHeaders()->set("Content-type", strtolower($type)."; charset=".$charset); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | 'Last-Modified' |
| 38 | 38 | ]; |
| 39 | 39 | |
| 40 | - foreach ($cleanup as $header) { |
|
| 40 | + foreach ( $cleanup as $header ) { |
|
| 41 | 41 | $response->getHeaders() |
| 42 | 42 | ->delete($header); |
| 43 | 43 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $location = $response->getLocation()->get(); |
| 32 | 32 | |
| 33 | - if (empty($location)) { |
|
| 33 | + if ( empty($location) ) { |
|
| 34 | 34 | throw new Exception("Invalid location, cannot redirect"); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $content = $response->getContent(); |
| 40 | 40 | |
| 41 | - if (empty($content->get())) { |
|
| 41 | + if ( empty($content->get()) ) { |
|
| 42 | 42 | |
| 43 | 43 | $content->set(sprintf('<!DOCTYPE html> |
| 44 | 44 | <html> |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | 'Content-MD5', |
| 36 | 36 | 'Content-Type', |
| 37 | 37 | 'Last-Modified' |
| 38 | - ]; |
|
| 38 | + ]; |
|
| 39 | 39 | |
| 40 | 40 | foreach ($cleanup as $header) { |
| 41 | 41 | $response->getHeaders() |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | 'Last-Modified' |
| 38 | 38 | ]; |
| 39 | 39 | |
| 40 | - foreach ($cleanup as $header) { |
|
| 40 | + foreach ( $cleanup as $header ) { |
|
| 41 | 41 | $response->getHeaders() |
| 42 | 42 | ->delete($header); |
| 43 | 43 | } |
@@ -86,8 +86,7 @@ |
||
| 86 | 86 | public function get($status) { |
| 87 | 87 | |
| 88 | 88 | $preprocessor = $this->has($status) ? |
| 89 | - $this->preprocessors[$status] : |
|
| 90 | - $this->preprocessors[self::DEFAULT_STATUS]; |
|
| 89 | + $this->preprocessors[$status] : $this->preprocessors[self::DEFAULT_STATUS]; |
|
| 91 | 90 | |
| 92 | 91 | return ($preprocessor instanceof HttpStatusPreprocessorInterface) ? |
| 93 | 92 | $preprocessor : new $preprocessor; |