@@ -41,13 +41,13 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | private static function getHeaders() { |
| 43 | 43 | |
| 44 | - if ( function_exists('getallheaders') ) return getallheaders(); |
|
| 44 | + if (function_exists('getallheaders')) return getallheaders(); |
|
| 45 | 45 | |
| 46 | 46 | $headers = array(); |
| 47 | 47 | |
| 48 | - foreach ( $_SERVER as $name => $value ) { |
|
| 48 | + foreach ($_SERVER as $name => $value) { |
|
| 49 | 49 | |
| 50 | - if ( substr($name, 0, 5) == 'HTTP_' ) { |
|
| 50 | + if (substr($name, 0, 5) == 'HTTP_') { |
|
| 51 | 51 | |
| 52 | 52 | $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; |
| 53 | 53 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | private static function getParameters() { |
| 48 | 48 | |
| 49 | - switch( $_SERVER['REQUEST_METHOD'] ) { |
|
| 49 | + switch ($_SERVER['REQUEST_METHOD']) { |
|
| 50 | 50 | |
| 51 | 51 | case 'POST': |
| 52 | 52 | |
@@ -48,11 +48,11 @@ |
||
| 48 | 48 | |
| 49 | 49 | private static function urlGetAbsolute() { |
| 50 | 50 | |
| 51 | - $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://'; |
|
| 51 | + $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'; |
|
| 52 | 52 | |
| 53 | 53 | $uri = self::uriGetAbsolute(); |
| 54 | 54 | |
| 55 | - return ( $http . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') . $uri . "/" ); |
|
| 55 | + return ($http.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost').$uri."/"); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function set($content=null) { |
|
| 41 | + public function set($content = null) { |
|
| 42 | 42 | |
| 43 | - if ( !is_scalar($content) && $content != null ) { |
|
| 43 | + if (!is_scalar($content) && $content != null) { |
|
| 44 | 44 | |
| 45 | 45 | throw new Exception("Invalid HTTP content"); |
| 46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function type($type = null) { |
| 56 | 56 | |
| 57 | - if ( is_null($type) ) { |
|
| 57 | + if (is_null($type)) { |
|
| 58 | 58 | |
| 59 | 59 | return $this->type; |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function charset($charset = null) { |
| 70 | 70 | |
| 71 | - if ( is_null($charset) ) { |
|
| 71 | + if (is_null($charset)) { |
|
| 72 | 72 | |
| 73 | 73 | return $this->charset; |
| 74 | 74 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $output_class_name = "\\Comodojo\\Dispatcher\\Response\\Preprocessor\\Status".$status; |
| 63 | 63 | |
| 64 | 64 | // @TODO: this condition will be removed when all preprocessors ready |
| 65 | - if ( class_exists($output_class_name) ) { |
|
| 65 | + if (class_exists($output_class_name)) { |
|
| 66 | 66 | $output = new $output_class_name($this); |
| 67 | 67 | } else { |
| 68 | 68 | $output = new \Comodojo\Dispatcher\Response\Preprocessor\Status200($this); |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $output->consolidate(); |
| 72 | 72 | |
| 73 | - if ( $route != null ) { |
|
| 73 | + if ($route != null) { |
|
| 74 | 74 | $this->setClientCache($request, $route); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // extra checks |
| 78 | 78 | |
| 79 | - if ( $request->method->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) { |
|
| 79 | + if ($request->method->get() == 'HEAD' && !in_array($status, array(100, 101, 102, 204, 304))) { |
|
| 80 | 80 | $length = $this->content->length(); |
| 81 | 81 | $this->content->set(null); |
| 82 | 82 | if ($length) $this->headers->set('Content-Length', $length); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->headers->delete('Content-Length'); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( $request->version->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { |
|
| 89 | + if ($request->version->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { |
|
| 90 | 90 | $this->headers->set('pragma', 'no-cache'); |
| 91 | 91 | $this->headers->set('expires', -1); |
| 92 | 92 | } |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | // the cache layer will be improoved in future versions. |
| 107 | 107 | ) { |
| 108 | 108 | |
| 109 | - if ( $ttl > 0 ) { |
|
| 109 | + if ($ttl > 0) { |
|
| 110 | 110 | |
| 111 | - $this->headers->set("Cache-Control","max-age=".$ttl.", must-revalidate"); |
|
| 112 | - $this->headers->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->getTimestamp() + $ttl)." GMT"); |
|
| 111 | + $this->headers->set("Cache-Control", "max-age=".$ttl.", must-revalidate"); |
|
| 112 | + $this->headers->set("Expires", gmdate("D, d M Y H:i:s", (int)$this->getTimestamp()+$ttl)." GMT"); |
|
| 113 | 113 | |
| 114 | 114 | } else { |
| 115 | 115 | |
| 116 | - $this->headers->set("Cache-Control","no-cache, must-revalidate"); |
|
| 117 | - $this->headers->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT"); |
|
| 116 | + $this->headers->set("Cache-Control", "no-cache, must-revalidate"); |
|
| 117 | + $this->headers->set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function set($code) { |
| 50 | 50 | |
| 51 | - if ( !$this->codes->exists($code) ) { |
|
| 51 | + if (!$this->codes->exists($code)) { |
|
| 52 | 52 | |
| 53 | 53 | throw new Exception("Invalid HTTP Status Code $code"); |
| 54 | 54 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function description($code=null) { |
|
| 63 | + public function description($code = null) { |
|
| 64 | 64 | |
| 65 | - if ( is_null($code) ) return $this->codes->getMessage($this->status_code); |
|
| 65 | + if (is_null($code)) return $this->codes->getMessage($this->status_code); |
|
| 66 | 66 | |
| 67 | 67 | return $this->codes->getMessage($code); |
| 68 | 68 | |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | |
| 62 | 62 | $status = $this->response->status->get(); |
| 63 | 63 | |
| 64 | - if ( !$this->codes->exists($status) ) throw new Exception("Invalid HTTP status code in response"); |
|
| 64 | + if (!$this->codes->exists($status)) throw new Exception("Invalid HTTP status code in response"); |
|
| 65 | 65 | |
| 66 | 66 | $message = $this->codes->getMessage($status); |
| 67 | 67 | |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | |
| 103 | 103 | public function getMessage($code) { |
| 104 | 104 | |
| 105 | - if ( $this->exists($code) ) return $this->codes[$code]; |
|
| 105 | + if ($this->exists($code)) return $this->codes[$code]; |
|
| 106 | 106 | |
| 107 | 107 | throw new Exception("Invalid HTTP status code $code"); |
| 108 | 108 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function getServiceName() { |
| 74 | 74 | |
| 75 | - return (empty($this->service))?"default":implode('.', $this->service); |
|
| 75 | + return (empty($this->service)) ? "default" : implode('.', $this->service); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $parameters = $this->parameters; |
| 98 | 98 | |
| 99 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 99 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $parameters = $this->request; |
| 128 | 128 | |
| 129 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 129 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $query = $this->query; |
| 171 | 171 | |
| 172 | - return isset($query[$key])?$query[$key]["required"]:false; |
|
| 172 | + return isset($query[$key]) ? $query[$key]["required"] : false; |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $query = $this->query; |
| 179 | 179 | |
| 180 | - return isset($query[$key])?$query[$key]["regex"]:null; |
|
| 180 | + return isset($query[$key]) ? $query[$key]["regex"] : null; |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /* if it's available a bit associated with the parameter name, it is compared against |
| 219 | 219 | * it's regular expression in order to extrect backreferences |
| 220 | 220 | */ |
| 221 | - if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) { |
|
| 221 | + if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) { |
|
| 222 | 222 | |
| 223 | 223 | if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
| 224 | 224 | |