@@ -186,8 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | $this->cache = false; |
188 | 188 | |
189 | - } |
|
190 | - else { |
|
189 | + } else { |
|
191 | 190 | |
192 | 191 | $cache = strtoupper($cache); |
193 | 192 | |
@@ -279,7 +278,9 @@ discard block |
||
279 | 278 | */ |
280 | 279 | public function getHeader($header) { |
281 | 280 | |
282 | - if ( isset($this->headers[$header]) ) return $this->headers[$header]; |
|
281 | + if ( isset($this->headers[$header]) ) { |
|
282 | + return $this->headers[$header]; |
|
283 | + } |
|
283 | 284 | |
284 | 285 | return null; |
285 | 286 | |
@@ -344,9 +345,11 @@ discard block |
||
344 | 345 | */ |
345 | 346 | public function getParameter($parameter) { |
346 | 347 | |
347 | - if ( isset($this->parameters[$parameter]) ) return $this->parameters[$parameter]; |
|
348 | - |
|
349 | - else return null; |
|
348 | + if ( isset($this->parameters[$parameter]) ) { |
|
349 | + return $this->parameters[$parameter]; |
|
350 | + } else { |
|
351 | + return null; |
|
352 | + } |
|
350 | 353 | |
351 | 354 | } |
352 | 355 |
@@ -39,7 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | final public function toJson($data, $flags=null) { |
41 | 41 | |
42 | - if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for JSON serialization"); |
|
42 | + if ( !( is_array($data) OR is_object($data) ) ) { |
|
43 | + throw new Exception("Invalid data for JSON serialization"); |
|
44 | + } |
|
43 | 45 | |
44 | 46 | return json_encode($data, $flags); |
45 | 47 | |
@@ -57,9 +59,13 @@ discard block |
||
57 | 59 | */ |
58 | 60 | final public function toXml($data, $prettify=false) { |
59 | 61 | |
60 | - if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for XML serialization"); |
|
62 | + if ( !( is_array($data) OR is_object($data) ) ) { |
|
63 | + throw new Exception("Invalid data for XML serialization"); |
|
64 | + } |
|
61 | 65 | |
62 | - if ( is_object($data) ) $data = $this->objectToArray($data); |
|
66 | + if ( is_object($data) ) { |
|
67 | + $data = $this->objectToArray($data); |
|
68 | + } |
|
63 | 69 | |
64 | 70 | $xmlEngine = new XML(); |
65 | 71 | |
@@ -103,9 +109,13 @@ discard block |
||
103 | 109 | */ |
104 | 110 | final public function toYaml($data) { |
105 | 111 | |
106 | - if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for XML serialization"); |
|
112 | + if ( !( is_array($data) OR is_object($data) ) ) { |
|
113 | + throw new Exception("Invalid data for XML serialization"); |
|
114 | + } |
|
107 | 115 | |
108 | - if ( is_object($data) ) $data = $this->objectToArray($data); |
|
116 | + if ( is_object($data) ) { |
|
117 | + $data = $this->objectToArray($data); |
|
118 | + } |
|
109 | 119 | |
110 | 120 | return \Spyc::YAMLDump($data); |
111 | 121 | |
@@ -158,7 +168,9 @@ discard block |
||
158 | 168 | |
159 | 169 | foreach($xmlStringArray as $k=>$tag){ |
160 | 170 | |
161 | - if ($tag == "") continue; |
|
171 | + if ($tag == "") { |
|
172 | + continue; |
|
173 | + } |
|
162 | 174 | |
163 | 175 | if ($tag[0]=="<" AND $tag[1] != "/") { |
164 | 176 | |
@@ -203,9 +215,9 @@ discard block |
||
203 | 215 | |
204 | 216 | return $array; |
205 | 217 | |
218 | + } else { |
|
219 | + return $stdObj; |
|
206 | 220 | } |
207 | - |
|
208 | - else return $stdObj; |
|
209 | 221 | |
210 | 222 | } |
211 | 223 |
@@ -95,8 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | return false; |
97 | 97 | |
98 | - } |
|
99 | - else { |
|
98 | + } else { |
|
100 | 99 | |
101 | 100 | $this->logger->error('Empty data, nothign to cache'); |
102 | 101 | |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | |
121 | 120 | if ($this->fail_silently) { |
122 | 121 | return false; |
123 | - } |
|
124 | - else { |
|
122 | + } else { |
|
125 | 123 | throw new IOException("Error writing to cache"); |
126 | 124 | } |
127 | 125 | } |
@@ -176,8 +174,7 @@ discard block |
||
176 | 174 | |
177 | 175 | return false; |
178 | 176 | |
179 | - } |
|
180 | - else { |
|
177 | + } else { |
|
181 | 178 | |
182 | 179 | throw new IOException("Error reading from cache"); |
183 | 180 | |
@@ -191,10 +188,10 @@ discard block |
||
191 | 188 | "object" => $u_data |
192 | 189 | ); |
193 | 190 | |
191 | + } else { |
|
192 | + return false; |
|
194 | 193 | } |
195 | 194 | |
196 | - else return false; |
|
197 | - |
|
198 | 195 | } |
199 | 196 | |
200 | 197 | /** |
@@ -226,17 +223,20 @@ discard block |
||
226 | 223 | while( false !== ( $cache_file = readdir($cache_path) ) ) { |
227 | 224 | |
228 | 225 | if ( pathinfo($cache_file, PATHINFO_EXTENSION) == "cache" ) { |
229 | - if ( unlink( $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cache_file ) == false ) return false; |
|
230 | - else $cache_files_number++; |
|
226 | + if ( unlink( $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cache_file ) == false ) { |
|
227 | + return false; |
|
228 | + } else { |
|
229 | + $cache_files_number++; |
|
230 | + } |
|
231 | + } else { |
|
232 | + continue; |
|
231 | 233 | } |
232 | - else continue; |
|
233 | 234 | |
234 | 235 | } |
235 | 236 | |
236 | 237 | closedir($cache_path); |
237 | 238 | |
238 | - } |
|
239 | - else { |
|
239 | + } else { |
|
240 | 240 | |
241 | 241 | $this->logger->info('Purging request cache', array( |
242 | 242 | 'REQUEST' => $request |
@@ -251,8 +251,9 @@ discard block |
||
251 | 251 | $unlink = unlink($cacheFile); |
252 | 252 | $cache_files_number = $unlink ? 1 : false; |
253 | 253 | |
254 | + } else { |
|
255 | + $cache_files_number = 0; |
|
254 | 256 | } |
255 | - else $cache_files_number = 0; |
|
256 | 257 | |
257 | 258 | } |
258 | 259 |
@@ -121,7 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | // If service is null, route to landing or (if not specified) to default route |
123 | 123 | |
124 | - if ( empty($service) ) return $this->routeToLanding(); |
|
124 | + if ( empty($service) ) { |
|
125 | + return $this->routeToLanding(); |
|
126 | + } |
|
125 | 127 | |
126 | 128 | // If service is in table, check if it is routable (in case of "ROUTE" route). |
127 | 129 | // If true, route request |
@@ -131,14 +133,16 @@ discard block |
||
131 | 133 | |
132 | 134 | if ( $this->table[$service]["type"] == "ROUTE" ) { |
133 | 135 | |
134 | - if ( $this->routable($this->table[$service]["target"]) ) return $this->table[$service]; |
|
135 | - |
|
136 | - else return $this->routeToNowhere(); |
|
136 | + if ( $this->routable($this->table[$service]["target"]) ) { |
|
137 | + return $this->table[$service]; |
|
138 | + } else { |
|
139 | + return $this->routeToNowhere(); |
|
140 | + } |
|
137 | 141 | |
142 | + } else { |
|
143 | + return $this->table[$service]; |
|
138 | 144 | } |
139 | 145 | |
140 | - else return $this->table[$service]; |
|
141 | - |
|
142 | 146 | } |
143 | 147 | |
144 | 148 | // If autoroute is enabled, try to match service name with a service file. |
@@ -156,7 +160,9 @@ discard block |
||
156 | 160 | |
157 | 161 | // If a route cannot be traced, emit a 404 - not found - response |
158 | 162 | |
159 | - else return $this->routeToNotfound(); |
|
163 | + else { |
|
164 | + return $this->routeToNotfound(); |
|
165 | + } |
|
160 | 166 | |
161 | 167 | } |
162 | 168 | |
@@ -180,9 +186,11 @@ discard block |
||
180 | 186 | */ |
181 | 187 | private function routable($target, $relative=false) { |
182 | 188 | |
183 | - if ( $relative ) return is_readable(DISPATCHER_SERVICES_FOLDER.$target) ? true : false; |
|
184 | - |
|
185 | - else return is_readable($target) ? true : false; |
|
189 | + if ( $relative ) { |
|
190 | + return is_readable(DISPATCHER_SERVICES_FOLDER.$target) ? true : false; |
|
191 | + } else { |
|
192 | + return is_readable($target) ? true : false; |
|
193 | + } |
|
186 | 194 | |
187 | 195 | } |
188 | 196 | |
@@ -197,10 +205,10 @@ discard block |
||
197 | 205 | |
198 | 206 | return $this->table[""]; |
199 | 207 | |
208 | + } else { |
|
209 | + return $this->routeToDefault(); |
|
200 | 210 | } |
201 | 211 | |
202 | - else return $this->routeToDefault(); |
|
203 | - |
|
204 | 212 | } |
205 | 213 | |
206 | 214 | /** |
@@ -214,10 +222,10 @@ discard block |
||
214 | 222 | |
215 | 223 | return $this->table["default"]; |
216 | 224 | |
225 | + } else { |
|
226 | + return $this->routeToNotfound(); |
|
217 | 227 | } |
218 | 228 | |
219 | - else return $this->routeToNotfound(); |
|
220 | - |
|
221 | 229 | } |
222 | 230 | |
223 | 231 | /** |
@@ -165,9 +165,11 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function setAttribute($name=null, $value) { |
167 | 167 | |
168 | - if ( is_null($name) ) array_push($this->attributes, $value); |
|
169 | - |
|
170 | - else $this->attributes[$name] = $value; |
|
168 | + if ( is_null($name) ) { |
|
169 | + array_push($this->attributes, $value); |
|
170 | + } else { |
|
171 | + $this->attributes[$name] = $value; |
|
172 | + } |
|
171 | 173 | |
172 | 174 | return $this; |
173 | 175 | |
@@ -417,7 +419,9 @@ discard block |
||
417 | 419 | */ |
418 | 420 | public function getHeader($header) { |
419 | 421 | |
420 | - if ( isset($this->headers[$header]) ) return $this->headers[$header]; |
|
422 | + if ( isset($this->headers[$header]) ) { |
|
423 | + return $this->headers[$header]; |
|
424 | + } |
|
421 | 425 | |
422 | 426 | return null; |
423 | 427 |
@@ -77,9 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | final public function get($header) { |
79 | 79 | |
80 | - if ( array_key_exists($header, $this->headers) ) return $this->headers[$header]; |
|
81 | - |
|
82 | - else return null; |
|
80 | + if ( array_key_exists($header, $this->headers) ) { |
|
81 | + return $this->headers[$header]; |
|
82 | + } else { |
|
83 | + return null; |
|
84 | + } |
|
83 | 85 | |
84 | 86 | } |
85 | 87 | |
@@ -163,10 +165,16 @@ discard block |
||
163 | 165 | |
164 | 166 | case 304: //Not Modified |
165 | 167 | |
166 | - if ( $value === false ) header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified'); |
|
167 | - else header('Last-Modified: '.gmdate('D, d M Y H:i:s', $value).' GMT', true, 304); |
|
168 | + if ( $value === false ) { |
|
169 | + header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified'); |
|
170 | + } else { |
|
171 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $value).' GMT', true, 304); |
|
172 | + } |
|
168 | 173 | |
169 | - if ($contentLength !== 0) header('Content-Length: '.$contentLength); //is it needed? |
|
174 | + if ($contentLength !== 0) { |
|
175 | + header('Content-Length: '.$contentLength); |
|
176 | + } |
|
177 | + //is it needed? |
|
170 | 178 | |
171 | 179 | $this->processExtraHeaders($this->headers); |
172 | 180 | |
@@ -240,8 +248,7 @@ discard block |
||
240 | 248 | if ( $ttl > 0 ) { |
241 | 249 | $this->set("Cache-Control","max-age=".$ttl.", must-revalidate"); |
242 | 250 | $this->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->current_time + $ttl)." GMT"); |
243 | - } |
|
244 | - else { |
|
251 | + } else { |
|
245 | 252 | $this->set("Cache-Control","no-cache, must-revalidate"); |
246 | 253 | $this->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT"); |
247 | 254 | } |
@@ -260,8 +267,11 @@ discard block |
||
260 | 267 | public function setContentType($type, $charset=null) { |
261 | 268 | |
262 | 269 | |
263 | - if ( is_null($charset) ) $this->set("Content-type",strtolower($type)); |
|
264 | - else $this->set("Content-type",strtolower($type)."; charset=".$charset); |
|
270 | + if ( is_null($charset) ) { |
|
271 | + $this->set("Content-type",strtolower($type)); |
|
272 | + } else { |
|
273 | + $this->set("Content-type",strtolower($type)."; charset=".$charset); |
|
274 | + } |
|
265 | 275 | |
266 | 276 | return $this; |
267 | 277 | |
@@ -276,13 +286,15 @@ discard block |
||
276 | 286 | |
277 | 287 | $headers = ''; |
278 | 288 | |
279 | - if (function_exists('getallheaders')) $headers = getallheaders(); |
|
280 | - |
|
281 | - else { |
|
289 | + if (function_exists('getallheaders')) { |
|
290 | + $headers = getallheaders(); |
|
291 | + } else { |
|
282 | 292 | |
283 | 293 | foreach ($_SERVER as $name => $value) { |
284 | 294 | |
285 | - if (substr($name, 0, 5) == 'HTTP_') $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; |
|
295 | + if (substr($name, 0, 5) == 'HTTP_') { |
|
296 | + $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; |
|
297 | + } |
|
286 | 298 | } |
287 | 299 | |
288 | 300 | } |
@@ -300,8 +312,11 @@ discard block |
||
300 | 312 | |
301 | 313 | foreach ( $headers as $header => $value ) { |
302 | 314 | |
303 | - if ( is_null($value) ) header($header, true); |
|
304 | - else header($header.": ".$value, true); |
|
315 | + if ( is_null($value) ) { |
|
316 | + header($header, true); |
|
317 | + } else { |
|
318 | + header($header.": ".$value, true); |
|
319 | + } |
|
305 | 320 | |
306 | 321 | } |
307 | 322 |
@@ -175,7 +175,9 @@ |
||
175 | 175 | */ |
176 | 176 | public function getHeader($header) { |
177 | 177 | |
178 | - if ( isset($this->headers[$header]) ) return $this->headers[$header]; |
|
178 | + if ( isset($this->headers[$header]) ) { |
|
179 | + return $this->headers[$header]; |
|
180 | + } |
|
179 | 181 | |
180 | 182 | return null; |
181 | 183 |
@@ -48,8 +48,7 @@ |
||
48 | 48 | |
49 | 49 | $handler = is_null($target) ? new ErrorLogHandler() : new StreamHandler( defined('DISPATCHER_LOG_FOLDER') ? DISPATCHER_LOG_FOLDER.$target : $target, $level); |
50 | 50 | |
51 | - } |
|
52 | - else { |
|
51 | + } else { |
|
53 | 52 | |
54 | 53 | $handler = new NullHandler($level); |
55 | 54 |
@@ -210,7 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | $xml = $this->ObjectXML->asXML(); |
212 | 212 | |
213 | - if ( $xml === false ) throw new XMLException("Error formatting object"); |
|
213 | + if ( $xml === false ) { |
|
214 | + throw new XMLException("Error formatting object"); |
|
215 | + } |
|
214 | 216 | |
215 | 217 | return $xml; |
216 | 218 | |
@@ -231,7 +233,9 @@ discard block |
||
231 | 233 | |
232 | 234 | $parser_structs = xml_parse_into_struct($this->parser, $xml, $this->struct, $index); |
233 | 235 | |
234 | - if ( $parser_structs === 0 ) throw new XMLException("Failed to parse xml data into structs"); |
|
236 | + if ( $parser_structs === 0 ) { |
|
237 | + throw new XMLException("Failed to parse xml data into structs"); |
|
238 | + } |
|
235 | 239 | |
236 | 240 | $this->counter = count($this->struct); |
237 | 241 | |
@@ -350,11 +354,15 @@ discard block |
||
350 | 354 | |
351 | 355 | if ( !isset($target[$key]) ) { |
352 | 356 | |
353 | - if ($child != "") $target[$key] = $child; |
|
354 | - |
|
355 | - if ($attributes != "") foreach($attributes as $akey => $avalue) $target[$key][$akey] = $avalue; |
|
357 | + if ($child != "") { |
|
358 | + $target[$key] = $child; |
|
359 | + } |
|
356 | 360 | |
357 | - else if ( $value != "" ) $target[$key] = $value; |
|
361 | + if ($attributes != "") { |
|
362 | + foreach($attributes as $akey => $avalue) $target[$key][$akey] = $avalue; |
|
363 | + } else if ( $value != "" ) { |
|
364 | + $target[$key] = $value; |
|
365 | + } |
|
358 | 366 | |
359 | 367 | } else { |
360 | 368 | |
@@ -365,18 +373,21 @@ discard block |
||
365 | 373 | $target[$key][0] = $oldval; |
366 | 374 | $index=1; |
367 | 375 | |
368 | - } |
|
369 | - else { |
|
376 | + } else { |
|
370 | 377 | |
371 | 378 | $index = count($target[$key]); |
372 | 379 | |
373 | 380 | } |
374 | 381 | |
375 | - if ( $child != "" ) $target[$key][$index] = $child; |
|
376 | - |
|
377 | - if ( $attributes != "" ) foreach($attributes as $akey => $avalue) $target[$key][$index][$akey] = $avalue; |
|
382 | + if ( $child != "" ) { |
|
383 | + $target[$key][$index] = $child; |
|
384 | + } |
|
378 | 385 | |
379 | - elseif ( $value != "" ) $target[$key][$index] = $value; |
|
386 | + if ( $attributes != "" ) { |
|
387 | + foreach($attributes as $akey => $avalue) $target[$key][$index][$akey] = $avalue; |
|
388 | + } elseif ( $value != "" ) { |
|
389 | + $target[$key][$index] = $value; |
|
390 | + } |
|
380 | 391 | } |
381 | 392 | |
382 | 393 | return $target; |
@@ -393,9 +404,11 @@ discard block |
||
393 | 404 | |
394 | 405 | foreach ($data as $key => $value) { |
395 | 406 | |
396 | - if ( is_array($value) ) $this->pushElement($ObjectXML->addChild(is_numeric($key) ? 'KEY_'.$key : $key), $value); |
|
397 | - |
|
398 | - else $ObjectXML->addChild(is_numeric($key) ? 'KEY_'.$key : $key, mb_convert_encoding($value, $this->encoding)); |
|
407 | + if ( is_array($value) ) { |
|
408 | + $this->pushElement($ObjectXML->addChild(is_numeric($key) ? 'KEY_'.$key : $key), $value); |
|
409 | + } else { |
|
410 | + $ObjectXML->addChild(is_numeric($key) ? 'KEY_'.$key : $key, mb_convert_encoding($value, $this->encoding)); |
|
411 | + } |
|
399 | 412 | |
400 | 413 | } |
401 | 414 |