@@ -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 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function getLocalName() { |
63 | 63 | |
64 | 64 | if (!empty($this->path)) |
65 | - return $this->path . "/" . $this->slug; |
|
65 | + return $this->path."/".$this->slug; |
|
66 | 66 | else |
67 | 67 | return ''; |
68 | 68 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | !empty($this->path) && |
118 | 118 | !empty($this->slug) && |
119 | 119 | file_exists($this->getLocalName()) && |
120 | - file_exists($this->getLocalName() . ".data") |
|
120 | + file_exists($this->getLocalName().".data") |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | private function loadFileInfo() { |
204 | 204 | |
205 | - $info = $this->getLocalName() . ".data"; |
|
205 | + $info = $this->getLocalName().".data"; |
|
206 | 206 | |
207 | 207 | if (file_exists($info)) { |
208 | 208 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | private function saveFileInfo() { |
225 | 225 | |
226 | - $info = $this->getLocalName() . ".data"; |
|
226 | + $info = $this->getLocalName().".data"; |
|
227 | 227 | |
228 | 228 | if (!empty($this->path) && file_exists($this->path)) { |
229 | 229 | |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | |
249 | 249 | preg_match_all("/[a-z0-9]+/", iconv("UTF-8", "ASCII//TRANSLIT", strtolower(preg_replace('/\..*?$/', '', $this->fname))), $matches); |
250 | 250 | |
251 | - $this->slug = implode('-', $matches[0]); |
|
251 | + $this->slug = implode('-', $matches[0]); |
|
252 | 252 | |
253 | 253 | if (!empty($this->path)) { |
254 | 254 | |
255 | - $files = glob($this->path . "/" . $slug . "*"); |
|
255 | + $files = glob($this->path."/".$slug."*"); |
|
256 | 256 | |
257 | - $count = count ($files); |
|
257 | + $count = count($files); |
|
258 | 258 | |
259 | 259 | if ($count > 0) { |
260 | 260 | |
261 | - $this->slug .= "-" . $count; |
|
261 | + $this->slug .= "-".$count; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 |
@@ -61,10 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | public function getLocalName() { |
63 | 63 | |
64 | - if (!empty($this->path)) |
|
65 | - return $this->path . "/" . $this->slug; |
|
66 | - else |
|
67 | - return ''; |
|
64 | + if (!empty($this->path)) { |
|
65 | + return $this->path . "/" . $this->slug; |
|
66 | + } else { |
|
67 | + return ''; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | } |
70 | 71 | |
@@ -101,11 +102,13 @@ discard block |
||
101 | 102 | public function getFileData() { |
102 | 103 | |
103 | 104 | $file = $this->getTemporaryName(); |
104 | - if (empty($file)) |
|
105 | - $file = $this->getLocalName(); |
|
105 | + if (empty($file)) { |
|
106 | + $file = $this->getLocalName(); |
|
107 | + } |
|
106 | 108 | |
107 | - if (file_exists($file)) |
|
108 | - return file_get_contents($file); |
|
109 | + if (file_exists($file)) { |
|
110 | + return file_get_contents($file); |
|
111 | + } |
|
109 | 112 | |
110 | 113 | throw new DispatcherException("File does not exists"); |
111 | 114 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * |
42 | 42 | * @param string $data Serialized data |
43 | 43 | * |
44 | - * @return Routes $this |
|
44 | + * @return boolean $this |
|
45 | 45 | */ |
46 | 46 | public function unserialize($data) { |
47 | 47 |
@@ -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 |
@@ -79,7 +79,9 @@ |
||
79 | 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 | - if ($length) $this->headers->set('Content-Length', $length); |
|
82 | + if ($length) { |
|
83 | + $this->headers->set('Content-Length', $length); |
|
84 | + } |
|
83 | 85 | } |
84 | 86 | |
85 | 87 | if ($this->headers->get('Transfer-Encoding') != null) { |
@@ -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 |
@@ -62,7 +62,9 @@ |
||
62 | 62 | |
63 | 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) ) { |
|
66 | + return $this->codes->getMessage($this->status_code); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | return $this->codes->getMessage($code); |
68 | 70 |
@@ -28,9 +28,9 @@ |
||
28 | 28 | |
29 | 29 | public function consolidate() { |
30 | 30 | |
31 | - $this->response->content>set(null); |
|
32 | - $this->response->headers>delete('Content-Type'); |
|
33 | - $this->response->headers>delete('Content-Length'); |
|
31 | + $this->response->content > set(null); |
|
32 | + $this->response->headers > delete('Content-Type'); |
|
33 | + $this->response->headers > delete('Content-Length'); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | $location = $this->response->location->get(); |
32 | 32 | |
33 | - if ( $location != null ) $this->response->headers->set("Location: ".$location); |
|
33 | + if ($location != null) $this->response->headers->set("Location: ".$location); |
|
34 | 34 | |
35 | 35 | parent::consolidate(); |
36 | 36 |
@@ -30,7 +30,9 @@ |
||
30 | 30 | |
31 | 31 | $location = $this->response->location->get(); |
32 | 32 | |
33 | - if ( $location != null ) $this->response->headers->set("Location: ".$location); |
|
33 | + if ( $location != null ) { |
|
34 | + $this->response->headers->set("Location: ".$location); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | parent::consolidate(); |
36 | 38 |
@@ -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 |
@@ -61,7 +61,9 @@ |
||
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) ) { |
|
65 | + throw new Exception("Invalid HTTP status code in response"); |
|
66 | + } |
|
65 | 67 | |
66 | 68 | $message = $this->codes->getMessage($status); |
67 | 69 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | public function __get($name) { |
31 | 31 | |
32 | - if ( array_key_exists($name, $this->data) ) { |
|
32 | + if (array_key_exists($name, $this->data)) { |
|
33 | 33 | |
34 | 34 | return $this->data[$name]; |
35 | 35 |