@@ -33,7 +33,7 @@ |
||
33 | 33 | $type = $this->response()->content()->type(); |
34 | 34 | $charset = $this->response()->content()->charset(); |
35 | 35 | |
36 | - if ( is_null($charset) ) { |
|
36 | + if (is_null($charset)) { |
|
37 | 37 | $this->response()->headers()->set("Content-type", strtolower($type)); |
38 | 38 | } else { |
39 | 39 | $this->response()->headers()->set("Content-type", strtolower($type)."; charset=".$charset); |
@@ -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 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $output_class_name = "\\Comodojo\\Dispatcher\\Response\\Preprocessor\\Status".$status; |
103 | 103 | |
104 | 104 | // @TODO: this condition will be removed when all preprocessors ready |
105 | - if ( class_exists($output_class_name) ) { |
|
105 | + if (class_exists($output_class_name)) { |
|
106 | 106 | $output = new $output_class_name($this); |
107 | 107 | } else { |
108 | 108 | $output = new \Comodojo\Dispatcher\Response\Preprocessor\Status200($this); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | |
111 | 111 | $output->consolidate(); |
112 | 112 | |
113 | - if ( $route != null ) { |
|
113 | + if ($route != null) { |
|
114 | 114 | $this->setClientCache($request, $route); |
115 | 115 | } |
116 | 116 | |
117 | 117 | // extra checks |
118 | 118 | |
119 | - if ( $request->method()->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) { |
|
119 | + if ($request->method()->get() == 'HEAD' && !in_array($status, array(100, 101, 102, 204, 304))) { |
|
120 | 120 | $length = $this->content()->length(); |
121 | 121 | $this->content()->set(null); |
122 | 122 | if ($length) $this->headers()->set('Content-Length', $length); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $this->headers()->delete('Content-Length'); |
127 | 127 | } |
128 | 128 | |
129 | - if ( $request->version()->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { |
|
129 | + if ($request->version()->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { |
|
130 | 130 | $this->headers()->set('pragma', 'no-cache'); |
131 | 131 | $this->headers()->set('expires', -1); |
132 | 132 | } |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | // the cache layer will be improoved in future versions. |
147 | 147 | ) { |
148 | 148 | |
149 | - if ( $ttl > 0 ) { |
|
149 | + if ($ttl > 0) { |
|
150 | 150 | |
151 | - $this->headers()->set("Cache-Control","max-age=".$ttl.", must-revalidate"); |
|
152 | - $this->headers()->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->getTimestamp() + $ttl)." GMT"); |
|
151 | + $this->headers()->set("Cache-Control", "max-age=".$ttl.", must-revalidate"); |
|
152 | + $this->headers()->set("Expires", gmdate("D, d M Y H:i:s", (int)$this->getTimestamp()+$ttl)." GMT"); |
|
153 | 153 | |
154 | 154 | } else { |
155 | 155 | |
156 | - $this->headers()->set("Cache-Control","no-cache, must-revalidate"); |
|
157 | - $this->headers()->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT"); |
|
156 | + $this->headers()->set("Cache-Control", "no-cache, must-revalidate"); |
|
157 | + $this->headers()->set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 |
@@ -119,7 +119,9 @@ |
||
119 | 119 | if ( $request->method()->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) { |
120 | 120 | $length = $this->content()->length(); |
121 | 121 | $this->content()->set(null); |
122 | - if ($length) $this->headers()->set('Content-Length', $length); |
|
122 | + if ($length) { |
|
123 | + $this->headers()->set('Content-Length', $length); |
|
124 | + } |
|
123 | 125 | } |
124 | 126 | |
125 | 127 | if ($this->headers()->get('Transfer-Encoding') != null) { |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | $supported_methods = $this->configuration()->get('supported-http-methods'); |
98 | 98 | |
99 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
99 | + if (is_null($supported_methods)) $supported_methods = array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PURGE'); |
|
100 | 100 | |
101 | - if ( method_exists($this, 'any') ) { |
|
101 | + if (method_exists($this, 'any')) { |
|
102 | 102 | |
103 | 103 | return $supported_methods; |
104 | 104 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | |
107 | 107 | $implemented_methods = array(); |
108 | 108 | |
109 | - foreach ( $supported_methods as $method ) { |
|
109 | + foreach ($supported_methods as $method) { |
|
110 | 110 | |
111 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
111 | + if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getMethod($method) { |
124 | 124 | |
125 | - if ( method_exists($this, strtolower($method)) ) { |
|
125 | + if (method_exists($this, strtolower($method))) { |
|
126 | 126 | |
127 | 127 | return strtolower($method); |
128 | 128 | |
129 | - } else if ( method_exists($this, strtolower('any')) ) { |
|
129 | + } else if (method_exists($this, strtolower('any'))) { |
|
130 | 130 | |
131 | 131 | return 'any'; |
132 | 132 |
@@ -96,7 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | $supported_methods = $this->configuration()->get('supported-http-methods'); |
98 | 98 | |
99 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
99 | + if ( is_null($supported_methods) ) { |
|
100 | + $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
101 | + } |
|
100 | 102 | |
101 | 103 | if ( method_exists($this, 'any') ) { |
102 | 104 | |
@@ -108,7 +110,9 @@ discard block |
||
108 | 110 | |
109 | 111 | foreach ( $supported_methods as $method ) { |
110 | 112 | |
111 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
113 | + if ( method_exists($this, strtolower($method)) ) { |
|
114 | + array_push($implemented_methods,$method); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | } |
114 | 118 |
@@ -130,7 +130,7 @@ |
||
130 | 130 | |
131 | 131 | $status = $this->response->status()->get(); |
132 | 132 | |
133 | - if ( !array_key_exists($status, $this->codes) ) throw new Exception("Invalid HTTP status code in response"); |
|
133 | + if (!array_key_exists($status, $this->codes)) throw new Exception("Invalid HTTP status code in response"); |
|
134 | 134 | |
135 | 135 | $message = $this->codes[$status]; |
136 | 136 |
@@ -130,7 +130,9 @@ |
||
130 | 130 | |
131 | 131 | $status = $this->response->status()->get(); |
132 | 132 | |
133 | - if ( !array_key_exists($status, $this->codes) ) throw new Exception("Invalid HTTP status code in response"); |
|
133 | + if ( !array_key_exists($status, $this->codes) ) { |
|
134 | + throw new Exception("Invalid HTTP status code in response"); |
|
135 | + } |
|
134 | 136 | |
135 | 137 | $message = $this->codes[$status]; |
136 | 138 |