@@ -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 |
@@ -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 |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | public function load($routes) { |
123 | 123 | |
124 | - if ( !empty($routes) ) { |
|
124 | + if (!empty($routes)) { |
|
125 | 125 | |
126 | - foreach( $routes as $name => $route ) { |
|
126 | + foreach ($routes as $name => $route) { |
|
127 | 127 | |
128 | 128 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
129 | 129 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | private function readCache() { |
141 | 141 | |
142 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
142 | + if ($this->configuration->get('routing-table-cache') !== true) return; |
|
143 | 143 | |
144 | 144 | $this->routes = $this->cache->setNamespace('dispatcherinternals')->get("dispatcher-routes"); |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | private function dumpCache() { |
153 | 153 | |
154 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
154 | + if ($this->configuration->get('routing-table-cache') !== true) return; |
|
155 | 155 | |
156 | 156 | $ttl = $this->configuration->get('routing-table-ttl'); |
157 | 157 | |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | ->setClassName($class) // Class to be invoked |
171 | 171 | ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) |
172 | 172 | |
173 | - $this->logger->debug("ROUTE: " . implode("/", $folders)); |
|
173 | + $this->logger->debug("ROUTE: ".implode("/", $folders)); |
|
174 | 174 | |
175 | 175 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
176 | 176 | |
177 | 177 | // This method generate a global regular expression which will be able to match all the URI supported by the route |
178 | 178 | $regex = $this->parser->read($folders, $route); |
179 | 179 | |
180 | - $this->logger->debug("ROUTE: " . $regex); |
|
180 | + $this->logger->debug("ROUTE: ".$regex); |
|
181 | 181 | |
182 | 182 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
183 | 183 |
@@ -78,10 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | $regex = $this->regex($route); |
80 | 80 | |
81 | - if (isset($this->routes[$regex])) |
|
82 | - return $this->routes[$regex]; |
|
83 | - else |
|
84 | - return null; |
|
81 | + if (isset($this->routes[$regex])) { |
|
82 | + return $this->routes[$regex]; |
|
83 | + } else { |
|
84 | + return null; |
|
85 | + } |
|
85 | 86 | |
86 | 87 | } |
87 | 88 | |
@@ -139,7 +140,9 @@ discard block |
||
139 | 140 | |
140 | 141 | private function readCache() { |
141 | 142 | |
142 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
143 | + if ( $this->configuration->get('routing-table-cache') !== true ) { |
|
144 | + return; |
|
145 | + } |
|
143 | 146 | |
144 | 147 | $this->routes = $this->cache->setNamespace('dispatcherinternals')->get("dispatcher-routes"); |
145 | 148 | |
@@ -157,7 +160,9 @@ discard block |
||
157 | 160 | |
158 | 161 | private function dumpCache() { |
159 | 162 | |
160 | - if ( $this->configuration->get('routing-table-cache') !== true ) return; |
|
163 | + if ( $this->configuration->get('routing-table-cache') !== true ) { |
|
164 | + return; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | $ttl = $this->configuration->get('routing-table-ttl'); |
163 | 168 |
@@ -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 |
@@ -102,7 +102,9 @@ |
||
102 | 102 | |
103 | 103 | public function getMessage($code) { |
104 | 104 | |
105 | - if ( $this->exists($code) ) return $this->codes[$code]; |
|
105 | + if ( $this->exists($code) ) { |
|
106 | + return $this->codes[$code]; |
|
107 | + } |
|
106 | 108 | |
107 | 109 | throw new Exception("Invalid HTTP status code $code"); |
108 | 110 |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | |
63 | 63 | if ( |
64 | 64 | empty($log) || |
65 | - ( isset($log['enabled']) && $log['enabled'] === false ) || |
|
65 | + (isset($log['enabled']) && $log['enabled'] === false) || |
|
66 | 66 | empty($log['providers']) |
67 | 67 | ) { |
68 | 68 | |
69 | - $logger->pushHandler( new NullHandler( self::getLevel() ) ); |
|
69 | + $logger->pushHandler(new NullHandler(self::getLevel())); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $handler = $this->getHandler($provider, $parameters); |
76 | 76 | |
77 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
77 | + if ($handler instanceof HandlerInterface) $logger->pushHandler($handler); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | protected function getHandler($provider, $parameters) { |
103 | 103 | |
104 | - switch ( $parameters['type'] ) { |
|
104 | + switch ($parameters['type']) { |
|
105 | 105 | |
106 | 106 | case 'StreamHandler': |
107 | 107 | $handler = $this->getStreamHandler($provider, $parameters); |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | |
130 | 130 | $stream = $this->configuration->get('base-path').'/'.(empty($parameters['stream']) ? 'dispatcher.log' : $parameters['stream']); |
131 | 131 | |
132 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
132 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
133 | 133 | |
134 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
134 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
135 | 135 | |
136 | - $filePermission = self::getFilePermission( empty($parameters['filePermission']) ? null : $parameters['filePermission'] ); |
|
136 | + $filePermission = self::getFilePermission(empty($parameters['filePermission']) ? null : $parameters['filePermission']); |
|
137 | 137 | |
138 | - $useLocking = self::getLocking( empty($parameters['useLocking']) ? false : $parameters['useLocking'] ); |
|
138 | + $useLocking = self::getLocking(empty($parameters['useLocking']) ? false : $parameters['useLocking']); |
|
139 | 139 | |
140 | 140 | return new StreamHandler($stream, $level, $bubble, $filePermission, $useLocking); |
141 | 141 | |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | |
144 | 144 | protected function getSyslogHandler($name, $parameters) { |
145 | 145 | |
146 | - if ( empty($parameters['ident']) ) return null; |
|
146 | + if (empty($parameters['ident'])) return null; |
|
147 | 147 | |
148 | 148 | $facility = empty($parameters['facility']) ? LOG_USER : $parameters['facility']; |
149 | 149 | |
150 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
150 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
151 | 151 | |
152 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
152 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
153 | 153 | |
154 | 154 | $logopts = empty($parameters['logopts']) ? LOG_PID : $parameters['logopts']; |
155 | 155 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | |
162 | 162 | $messageType = empty($parameters['messageType']) ? ErrorLogHandler::OPERATING_SYSTEM : $parameters['messageType']; |
163 | 163 | |
164 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
164 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
165 | 165 | |
166 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
166 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
167 | 167 | |
168 | - $expandNewlines = self::getExpandNewlines( empty($parameters['expandNewlines']) ? false : $parameters['expandNewlines'] ); |
|
168 | + $expandNewlines = self::getExpandNewlines(empty($parameters['expandNewlines']) ? false : $parameters['expandNewlines']); |
|
169 | 169 | |
170 | 170 | return new ErrorLogHandler($messageType, $level, $bubble, $expandNewlines); |
171 | 171 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $level = strtoupper($level); |
184 | 184 | |
185 | - if ( array_key_exists($level, self::$levels) ) return self::$levels[$level]; |
|
185 | + if (array_key_exists($level, self::$levels)) return self::$levels[$level]; |
|
186 | 186 | |
187 | 187 | return self::$levels['DEBUG']; |
188 | 188 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | protected static function getFilePermission($filepermission = null) { |
202 | 202 | |
203 | - if ( is_null($filepermission) ) return null; |
|
203 | + if (is_null($filepermission)) return null; |
|
204 | 204 | |
205 | 205 | return filter_var($filepermission, FILTER_VALIDATE_INT, array( |
206 | 206 | 'options' => array( |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | |
75 | 75 | $handler = $this->getHandler($provider, $parameters); |
76 | 76 | |
77 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
77 | + if ( $handler instanceof HandlerInterface ) { |
|
78 | + $logger->pushHandler($handler); |
|
79 | + } |
|
78 | 80 | |
79 | 81 | } |
80 | 82 | |
@@ -143,7 +145,9 @@ discard block |
||
143 | 145 | |
144 | 146 | protected function getSyslogHandler($name, $parameters) { |
145 | 147 | |
146 | - if ( empty($parameters['ident']) ) return null; |
|
148 | + if ( empty($parameters['ident']) ) { |
|
149 | + return null; |
|
150 | + } |
|
147 | 151 | |
148 | 152 | $facility = empty($parameters['facility']) ? LOG_USER : $parameters['facility']; |
149 | 153 | |
@@ -182,7 +186,9 @@ discard block |
||
182 | 186 | |
183 | 187 | $level = strtoupper($level); |
184 | 188 | |
185 | - if ( array_key_exists($level, self::$levels) ) return self::$levels[$level]; |
|
189 | + if ( array_key_exists($level, self::$levels) ) { |
|
190 | + return self::$levels[$level]; |
|
191 | + } |
|
186 | 192 | |
187 | 193 | return self::$levels['DEBUG']; |
188 | 194 | |
@@ -200,7 +206,9 @@ discard block |
||
200 | 206 | |
201 | 207 | protected static function getFilePermission($filepermission = null) { |
202 | 208 | |
203 | - if ( is_null($filepermission) ) return null; |
|
209 | + if ( is_null($filepermission) ) { |
|
210 | + return null; |
|
211 | + } |
|
204 | 212 | |
205 | 213 | return filter_var($filepermission, FILTER_VALIDATE_INT, array( |
206 | 214 | 'options' => array( |
@@ -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 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | |
184 | 184 | preg_match_all("/[a-z0-9]+/", iconv("UTF-8", "ASCII//TRANSLIT", strtolower(preg_replace('/\..*?$/', '', $this->fname))), $matches); |
185 | 185 | |
186 | - $this->slug = implode('-', $matches[0]); |
|
186 | + $this->slug = implode('-', $matches[0]); |
|
187 | 187 | |
188 | 188 | if (!empty($this->path)) { |
189 | 189 | |
190 | - $files = glob($this->path . "/" . $slug . "*"); |
|
190 | + $files = glob($this->path."/".$slug."*"); |
|
191 | 191 | |
192 | - $count = count ($files); |
|
192 | + $count = count($files); |
|
193 | 193 | |
194 | 194 | if ($count > 0) { |
195 | 195 | |
196 | - $this->slug .= "-" . $count; |
|
196 | + $this->slug .= "-".$count; |
|
197 | 197 | |
198 | 198 | } |
199 | 199 |
@@ -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 | |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | |
103 | 104 | $file = $this->getTemporaryName(); |
104 | 105 | |
105 | - if (file_exists($file)) |
|
106 | - return file_get_contents($file); |
|
106 | + if (file_exists($file)) { |
|
107 | + return file_get_contents($file); |
|
108 | + } |
|
107 | 109 | |
108 | 110 | throw new DispatcherException("File does not exists"); |
109 | 111 |