Passed
Push — 1.0.0-dev ( 93958a...e1c8ef )
by nguereza
02:26
created
core/classes/Response.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -210,8 +210,7 @@  discard block
 block discarded – undo
210 210
 			if($moduleViewPath){
211 211
 				$path = $moduleViewPath;
212 212
 				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$moduleViewPath. '] we will used it');
213
-			}
214
-			else{
213
+			} else{
215 214
 				$logger->info('Cannot find view [' . $view . '] in module [' .$module. '] using the default location');
216 215
 			}
217 216
 			
@@ -335,8 +334,7 @@  discard block
 block discarded – undo
335 334
 				$output = ob_get_clean();
336 335
 				self::sendHeaders(404);
337 336
 				echo $output;
338
-			}
339
-			else{
337
+			} else{
340 338
 				show_error('The 404 view [' .$path. '] does not exist');
341 339
 			}
342 340
 		}
@@ -359,8 +357,7 @@  discard block
 block discarded – undo
359 357
 				$output = ob_get_clean();
360 358
 				self::sendHeaders(503);
361 359
 				echo $output;
362
-			}
363
-			else{
360
+			} else{
364 361
 				//can't use show_error() at this time because some dependencies not yet loaded and to prevent loop
365 362
 				set_http_status_header(503);
366 363
 				echo 'The error view [' . $path . '] does not exist';
Please login to merge, or discard this patch.
core/classes/model/Model.php 1 patch
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -148,8 +148,7 @@  discard block
 block discarded – undo
148 148
         public function __construct(Database $db = null){
149 149
             if (is_object($db)){
150 150
                 $this->setDatabaseInstance($db);
151
-            }
152
-            else{
151
+            } else{
153 152
                 $obj = & get_instance();
154 153
         		if (isset($obj->database) && is_object($obj->database)){
155 154
                     /**
@@ -265,8 +264,7 @@  discard block
 block discarded – undo
265 264
                 $this->trigger('after_create', $insert_id);
266 265
 				//if the table doesn't have the auto increment field or sequence, the value of 0 will be returned 
267 266
 				return ! $insert_id ? true : $insert_id;
268
-            }
269
-            else
267
+            } else
270 268
             {
271 269
                 return FALSE;
272 270
             }
@@ -303,8 +301,7 @@  discard block
 block discarded – undo
303 301
                 $result = $this->_database->update($data, $escape);
304 302
                 $this->trigger('after_update', array($data, $result));
305 303
                 return $result;
306
-            }
307
-            else
304
+            } else
308 305
             {
309 306
                 return FALSE;
310 307
             }
@@ -327,8 +324,7 @@  discard block
 block discarded – undo
327 324
 				$result = $this->_database->update($data, $escape);
328 325
                 $this->trigger('after_update', array($data, $result));
329 326
                 return $result;
330
-            }
331
-            else
327
+            } else
332 328
             {
333 329
                 return FALSE;
334 330
             }
@@ -345,8 +341,7 @@  discard block
 block discarded – undo
345 341
                 if (is_array($args[1])){
346 342
                     $data = array_pop($args);
347 343
                 }
348
-            }
349
-            else if (count($args) == 3){
344
+            } else if (count($args) == 3){
350 345
                 if (is_array($args[2])){
351 346
                     $data = array_pop($args);
352 347
                 }
@@ -387,8 +382,7 @@  discard block
 block discarded – undo
387 382
             {
388 383
                 $this->getQueryBuilder()->from($this->_table);	
389 384
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
390
-            }
391
-            else
385
+            } else
392 386
             {
393 387
                 $this->getQueryBuilder()->from($this->_table); 
394 388
 				$result = $this->_database->delete();
@@ -411,8 +405,7 @@  discard block
 block discarded – undo
411 405
             {
412 406
                 $this->getQueryBuilder()->from($this->_table);	
413 407
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
414
-            }
415
-            else
408
+            } else
416 409
             {
417 410
                 $this->getQueryBuilder()->from($this->_table); 
418 411
 				$result = $this->_database->delete();
@@ -433,8 +426,7 @@  discard block
 block discarded – undo
433 426
             {
434 427
                 $this->getQueryBuilder()->from($this->_table);	
435 428
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
436
-            }
437
-            else
429
+            } else
438 430
             {
439 431
                 $this->getQueryBuilder()->from($this->_table); 
440 432
 				$result = $this->_database->delete();
@@ -496,8 +488,7 @@  discard block
 block discarded – undo
496 488
             if (count($args) == 2)
497 489
             {
498 490
                 list($key, $value) = $args;
499
-            }
500
-            else
491
+            } else
501 492
             {
502 493
                 $key = $this->primary_key;
503 494
                 $value = $args[0];
@@ -649,8 +640,7 @@  discard block
 block discarded – undo
649 640
             if (is_object($row))
650 641
             {
651 642
                 $row->created_at = date('Y-m-d H:i:s');
652
-            }
653
-            else
643
+            } else
654 644
             {
655 645
                 $row['created_at'] = date('Y-m-d H:i:s');
656 646
             }
@@ -662,8 +652,7 @@  discard block
 block discarded – undo
662 652
             if (is_object($row))
663 653
             {
664 654
                 $row->updated_at = date('Y-m-d H:i:s');
665
-            }
666
-            else
655
+            } else
667 656
             {
668 657
                 $row['updated_at'] = date('Y-m-d H:i:s');
669 658
             }
@@ -690,8 +679,7 @@  discard block
 block discarded – undo
690 679
                 if (is_array($row))
691 680
                 {
692 681
                     $row[$column] = unserialize($row[$column]);
693
-                }
694
-                else
682
+                } else
695 683
                 {
696 684
                     $row->$column = unserialize($row->$column);
697 685
                 }
@@ -711,8 +699,7 @@  discard block
 block discarded – undo
711 699
 					if (isset($row->$attr)){
712 700
 						unset($row->$attr);
713 701
 					}
714
-                }
715
-                else
702
+                } else
716 703
                 {
717 704
 					if (isset($row[$attr])){
718 705
 						unset($row[$attr]);
@@ -812,8 +799,7 @@  discard block
 block discarded – undo
812 799
                 {
813 800
                     $this->getQueryBuilder()->orderBy($key, $value);
814 801
                 }
815
-            }
816
-            else
802
+            } else
817 803
             {
818 804
                 $this->getQueryBuilder()->orderBy($criteria, $order);
819 805
             }
@@ -844,8 +830,7 @@  discard block
 block discarded – undo
844 830
                 {
845 831
                     $relationship = $value;
846 832
                     $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' );
847
-                }
848
-                else
833
+                } else
849 834
                 {
850 835
                     $relationship = $key;
851 836
                     $options = $value;
@@ -855,15 +840,13 @@  discard block
 block discarded – undo
855 840
                 {
856 841
                     if (is_object($this->loaderInstance)){
857 842
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
858
-                    }
859
-                    else{
843
+                    } else{
860 844
                         Loader::model($options['model'], $relationship . '_model');    
861 845
                     }
862 846
                     if (is_object($row))
863 847
                     {
864 848
                         $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']});
865
-                    }
866
-                    else
849
+                    } else
867 850
                     {
868 851
                         $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]);
869 852
                     }
@@ -883,8 +866,7 @@  discard block
 block discarded – undo
883 866
                 {
884 867
                     $relationship = $value;
885 868
                     $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' );
886
-                }
887
-                else
869
+                } else
888 870
                 {
889 871
                     $relationship = $key;
890 872
                     $options = $value;
@@ -894,15 +876,13 @@  discard block
 block discarded – undo
894 876
                 {
895 877
                     if (is_object($this->loaderInstance)){
896 878
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
897
-                    }
898
-                    else{
879
+                    } else{
899 880
                         Loader::model($options['model'], $relationship . '_model');    
900 881
                     }
901 882
                     if (is_object($row))
902 883
                     {
903 884
                         $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key});
904
-                    }
905
-                    else
885
+                    } else
906 886
                     {
907 887
                         $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]);
908 888
                     }
@@ -970,14 +950,12 @@  discard block
 block discarded – undo
970 950
 				if (is_array($filter))
971 951
 				{
972 952
 					$this->getQueryBuilder()->in($field, $filter);
973
-				}
974
-				else
953
+				} else
975 954
 				{
976 955
 					if (is_int($field))
977 956
 					{
978 957
 						$this->getQueryBuilder()->where($filter);
979
-					}
980
-					else
958
+					} else
981 959
 					{
982 960
 						$this->getQueryBuilder()->where($field, $filter);
983 961
 					}
@@ -994,33 +972,27 @@  discard block
 block discarded – undo
994 972
             if (count($params) == 1 && is_array($params[0]))
995 973
             {
996 974
                 $this->_set_where_array($params[0]);
997
-            }
998
-            else if (count($params) == 1)
975
+            } else if (count($params) == 1)
999 976
             {
1000 977
                 $this->getQueryBuilder()->where($params[0]);
1001
-            }
1002
-        	else if (count($params) == 2)
978
+            } else if (count($params) == 2)
1003 979
     		{
1004 980
                 if (is_array($params[1]))
1005 981
                 {
1006 982
                     $this->getQueryBuilder()->in($params[0], $params[1]);
1007
-                }
1008
-                else
983
+                } else
1009 984
                 {
1010 985
                     $this->getQueryBuilder()->where($params[0], $params[1]);
1011 986
                 }
1012
-    		}
1013
-    		else if (count($params) == 3)
987
+    		} else if (count($params) == 3)
1014 988
     		{
1015 989
     			$this->getQueryBuilder()->where($params[0], $params[1], $params[2]);
1016
-    		}
1017
-            else
990
+    		} else
1018 991
             {
1019 992
                 if (is_array($params[1]))
1020 993
                 {
1021 994
                     $this->getQueryBuilder()->in($params[0], $params[1]);
1022
-                }
1023
-                else
995
+                } else
1024 996
                 {
1025 997
                     $this->getQueryBuilder()->where($params[0], $params[1]);
1026 998
                 }
Please login to merge, or discard this patch.
core/common.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -222,16 +222,14 @@  discard block
 block discarded – undo
222 222
 							);
223 223
 			if (isset($http_status[$code])){
224 224
 				$text = $http_status[$code];
225
-			}
226
-			else{
225
+			} else{
227 226
 				show_error('No HTTP status text found for your code please check it.');
228 227
 			}
229 228
 		}
230 229
 		
231 230
 		if (strpos(php_sapi_name(), 'cgi') === 0){
232 231
 			header('Status: ' . $code . ' ' . $text, TRUE);
233
-		}
234
-		else{
232
+		} else{
235 233
 			$proto = 'HTTP/1.1';
236 234
 			if(isset($_SERVER['SERVER_PROTOCOL'])){
237 235
 				$proto = $_SERVER['SERVER_PROTOCOL'];
@@ -323,8 +321,7 @@  discard block
 block discarded – undo
323 321
 	function php_exception_handler($ex){
324 322
 		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
325 323
 			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
326
-		}
327
-		else{
324
+		} else{
328 325
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
329 326
 		}
330 327
 		return true;
@@ -440,15 +437,13 @@  discard block
 block discarded – undo
440 437
 	function clean_input($str){
441 438
 		if (is_array($str)){
442 439
 			$str = array_map('clean_input', $str);
443
-		}
444
-		else if (is_object($str)){
440
+		} else if (is_object($str)){
445 441
 			$obj = $str;
446 442
 			foreach ($str as $var => $value) {
447 443
 				$obj->$var = clean_input($value);
448 444
 			}
449 445
 			$str = $obj;
450
-		}
451
-		else{
446
+		} else{
452 447
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
453 448
 		}
454 449
 		return $str;
@@ -521,8 +516,7 @@  discard block
 block discarded – undo
521 516
 					session_save_path($sessionSavePath);
522 517
 					$logger->info('Session save path: ' . $sessionSavePath);
523 518
 				}
524
-			}
525
-			else if ($sessionHandler == 'database'){
519
+			} else if ($sessionHandler == 'database'){
526 520
 				//load database session handle library
527 521
 				//Database Session handler Model
528 522
 				require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php';
@@ -530,8 +524,7 @@  discard block
 block discarded – undo
530 524
 				$DBS =& class_loader('DBSessionHandler', 'classes');
531 525
 				session_set_save_handler($DBS, true);
532 526
 				$logger->info('session save path: ' . get_config('session_save_path'));
533
-			}
534
-			else{
527
+			} else{
535 528
 				show_error('Invalid session handler configuration');
536 529
 			}
537 530
 			$lifetime = get_config('session_cookie_lifetime', 0);
Please login to merge, or discard this patch.
core/classes/Module.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@
 block discarded – undo
49 49
 				while(($module = readdir($moduleDir)) !== false){
50 50
 					if (preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
51 51
 						self::$list[] = $module;
52
-					}
53
-					else{
52
+					} else{
54 53
 						$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
55 54
 					}
56 55
 				}
Please login to merge, or discard this patch.
core/classes/Router.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -242,8 +242,7 @@  discard block
 block discarded – undo
242 242
 	    	//if the application is running in CLI mode use the first argument
243 243
 			else if(IS_CLI && isset($_SERVER['argv'][1])){
244 244
 				$routeUri = $_SERVER['argv'][1];
245
-			}
246
-			else if(isset($_SERVER['REQUEST_URI'])){
245
+			} else if(isset($_SERVER['REQUEST_URI'])){
247 246
 				$routeUri = $_SERVER['REQUEST_URI'];
248 247
 			}
249 248
 			$this->logger->debug('Check if URL suffix is enabled in the configuration');
@@ -339,15 +338,13 @@  discard block
 block discarded – undo
339 338
 				if(! class_exists($controller, false)){
340 339
 					$e404 = true;
341 340
 					$this->logger->warning('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
342
-				}
343
-				else{
341
+				} else{
344 342
 					$controllerInstance = new $controller();
345 343
 					$controllerMethod = $this->getMethod();
346 344
 					if(! method_exists($controllerInstance, $controllerMethod)){
347 345
 						$e404 = true;
348 346
 						$this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
349
-					}
350
-					else{
347
+					} else{
351 348
 						$this->logger->info('Routing data is set correctly now GO!');
352 349
 						call_user_func_array(array($controllerInstance, $controllerMethod), $this->args);
353 350
 						//render the final page to user
@@ -355,8 +352,7 @@  discard block
 block discarded – undo
355 352
 						get_instance()->response->renderFinalPage();
356 353
 					}
357 354
 				}
358
-			}
359
-			else{
355
+			} else{
360 356
 				$this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
361 357
 				$e404 = true;
362 358
 			}
@@ -462,8 +458,7 @@  discard block
 block discarded – undo
462 458
 						$this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']');
463 459
 						$this->module = $moduleControllerMethod[0];
464 460
 						$moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
465
-					}
466
-					else{
461
+					} else{
467 462
 						$this->logger->info('The current request does not use the module');
468 463
 						$moduleControllerMethod = explode('@', $this->callback[$index]);
469 464
 					}
@@ -519,8 +514,7 @@  discard block
 block discarded – undo
519 514
 					}
520 515
 					//args
521 516
 					$this->args = $segment;
522
-				}
523
-				else{
517
+				} else{
524 518
 					$this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
525 519
 					if(in_array($segment[0], $modules)){
526 520
 						$this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
@@ -534,8 +528,7 @@  discard block
 block discarded – undo
534 528
 							if(! $path){
535 529
 								$this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller');
536 530
 								$this->controller = $this->module;
537
-							}
538
-							else{
531
+							} else{
539 532
 								$this->controllerPath = $path;
540 533
 								array_shift($segment);
541 534
 							}
@@ -547,8 +540,7 @@  discard block
 block discarded – undo
547 540
 						}
548 541
 						//the remaining is for args
549 542
 						$this->args = $segment;
550
-					}
551
-					else{
543
+					} else{
552 544
 						$this->logger->info('The current request information is not found in the module list');
553 545
 						//controller
554 546
 						if(isset($segment[0])){
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@  discard block
 block discarded – undo
47 47
 			if($success === false){
48 48
 				$this->logger->info('No cache found for the key ['. $key .'], return false');
49 49
 				return false;
50
-			}
51
-			else{
50
+			} else{
52 51
 				$cacheInfo = $this->_getCacheInfo($key);
53 52
 				$expire = time();
54 53
 				if($cacheInfo){
@@ -74,8 +73,7 @@  discard block
 block discarded – undo
74 73
 			if($result === false){
75 74
 		    	$this->logger->error('Can not write cache data for the key ['. $key .'], return false');
76 75
 		    	return false;
77
-		    }
78
-		    else{
76
+		    } else{
79 77
 		    	$this->logger->info('Cache data saved for the key ['. $key .']');
80 78
 		    	return true;
81 79
 		    }
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
 			if($cacheInfo === false){
95 93
 				$this->logger->info('This cache data does not exists skipping');
96 94
 				return false;
97
-			}
98
-			else{
95
+			} else{
99 96
 				$this->logger->info('Found cache data for the key [' .$key. '] remove it');
100 97
 	      		return apc_delete($key) === true;
101 98
 			}
@@ -119,8 +116,7 @@  discard block
 block discarded – undo
119 116
 							'ttl' => $cacheInfos['ttl']
120 117
 							);
121 118
 				return $data;
122
-			}
123
-			else{
119
+			} else{
124 120
 				$this->logger->info('This cache does not exists skipping');
125 121
 				return false;
126 122
 			}
@@ -144,8 +140,7 @@  discard block
 block discarded – undo
144 140
 			if(empty($cacheInfos['cache_list'])){
145 141
 				$this->logger->info('No cache data were found skipping');
146 142
 				return false;
147
-			}
148
-			else{
143
+			} else{
149 144
 				$this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
150 145
 				return apc_clear_cache('user');
151 146
 			}
Please login to merge, or discard this patch.
core/classes/cache/FileCache.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 		        // Unlinking when the file was expired
83 83
 		        unlink($filePath);
84 84
 		        return false;
85
-		     }
86
-		     else{
85
+		     } else{
87 86
 		     	$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
88 87
 		     	return $data['data'];
89 88
 		     }
@@ -120,8 +119,7 @@  discard block
 block discarded – undo
120 119
 		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
121 120
 		    	fclose($handle);
122 121
 		    	return false;
123
-		    }
124
-		    else{
122
+		    } else{
125 123
 		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
126 124
 		    	fclose($handle);
127 125
 				chmod($filePath, 0640);
@@ -143,8 +141,7 @@  discard block
 block discarded – undo
143 141
 			if(! file_exists($filePath)){
144 142
 				$this->logger->info('This cache file does not exists skipping');
145 143
 				return false;
146
-			}
147
-			else{
144
+			} else{
148 145
 				$this->logger->info('Found cache file [' .$filePath. '] remove it');
149 146
 	      		unlink($filePath);
150 147
 				return true;
@@ -197,8 +194,7 @@  discard block
 block discarded – undo
197 194
 			$list = glob(CACHE_PATH . '*.cache');
198 195
 			if(! $list){
199 196
 				$this->logger->info('No cache files were found skipping');
200
-			}
201
-			else{
197
+			} else{
202 198
 				$this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
203 199
 				foreach ($list as $file) {
204 200
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -206,12 +202,10 @@  discard block
 block discarded – undo
206 202
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
207 203
 		      		if(! $data){
208 204
 		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
209
-		      		}
210
-		      		else if(time() > $data['expire']){
205
+		      		} else if(time() > $data['expire']){
211 206
 		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
212 207
 		      			unlink($file);
213
-		      		}
214
-		      		else{
208
+		      		} else{
215 209
 		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
216 210
 		      		}
217 211
 				}
@@ -226,8 +220,7 @@  discard block
 block discarded – undo
226 220
 			$list = glob(CACHE_PATH . '*.cache');
227 221
 			if(! $list){
228 222
 				$this->logger->info('No cache files were found skipping');
229
-			}
230
-			else{
223
+			} else{
231 224
 				$this->logger->info('Found [' . count($list) . '] cache files to remove');
232 225
 				foreach ($list as $file) {
233 226
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -254,8 +247,7 @@  discard block
 block discarded – undo
254 247
 				
255 248
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
256 249
 				$this->compressCacheData = false;
257
-			}
258
-			else{
250
+			} else{
259 251
 				$this->compressCacheData = $status;
260 252
 			}
261 253
 			return $this;
Please login to merge, or discard this patch.