Passed
Push — 1.0.0-dev ( ead601...e21083 )
by nguereza
04:39
created
tests/include/autoloader.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@
 block discarded – undo
43 43
 		if(isset($classesMap[$class])){
44 44
 			if(file_exists($classesMap[$class])){
45 45
 				require_once $classesMap[$class];
46
-			}
47
-			else{
46
+			} else{
48 47
 				echo 'File for class ' . $class . ' not found';
49 48
 			}
50 49
 		}
Please login to merge, or discard this patch.
core/common.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -226,16 +226,14 @@  discard block
 block discarded – undo
226 226
 							);
227 227
 			if (isset($http_status[$code])){
228 228
 				$text = $http_status[$code];
229
-			}
230
-			else{
229
+			} else{
231 230
 				show_error('No HTTP status text found for your code please check it.');
232 231
 			}
233 232
 		}
234 233
 		
235 234
 		if (strpos(php_sapi_name(), 'cgi') === 0){
236 235
 			header('Status: ' . $code . ' ' . $text, TRUE);
237
-		}
238
-		else{
236
+		} else{
239 237
 			$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
240 238
 			header($proto . ' ' . $code . ' ' . $text, TRUE, $code);
241 239
 		}
@@ -277,11 +275,9 @@  discard block
 block discarded – undo
277 275
 		*/
278 276
 		if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){
279 277
 			return true;
280
-		}
281
-		else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
278
+		} else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
282 279
 			return true;
283
-		}
284
-		else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
280
+		} else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
285 281
 			return true;
286 282
 		}
287 283
 		return false;
@@ -324,8 +320,7 @@  discard block
 block discarded – undo
324 320
 	function php_exception_handler($ex){
325 321
 		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
326 322
 			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
327
-		}
328
-		else{
323
+		} else{
329 324
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
330 325
 		}
331 326
 		return true;
@@ -447,15 +442,13 @@  discard block
 block discarded – undo
447 442
 	function clean_input($str){
448 443
 		if (is_array($str)){
449 444
 			$str = array_map('clean_input', $str);
450
-		}
451
-		else if (is_object($str)){
445
+		} else if (is_object($str)){
452 446
 			$obj = $str;
453 447
 			foreach ($str as $var => $value) {
454 448
 				$obj->$var = clean_input($value);
455 449
 			}
456 450
 			$str = $obj;
457
-		}
458
-		else{
451
+		} else{
459 452
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
460 453
 		}
461 454
 		return $str;
@@ -528,8 +521,7 @@  discard block
 block discarded – undo
528 521
 					session_save_path($sessionSavePath);
529 522
 					$logger->info('Session save path: ' . $sessionSavePath);
530 523
 				}
531
-			}
532
-			else if ($sessionHandler == 'database'){
524
+			} else if ($sessionHandler == 'database'){
533 525
 				//load database session handle library
534 526
 				//Database Session handler Model
535 527
 				require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php';
@@ -537,8 +529,7 @@  discard block
 block discarded – undo
537 529
 				$DBS =& class_loader('DBSessionHandler', 'classes');
538 530
 				session_set_save_handler($DBS, true);
539 531
 				$logger->info('session save path: ' . get_config('session_save_path'));
540
-			}
541
-			else{
532
+			} else{
542 533
 				show_error('Invalid session handler configuration');
543 534
 			}
544 535
 			$lifetime = get_config('session_cookie_lifetime', 0);
Please login to merge, or discard this patch.
core/classes/model/Model.php 1 patch
Braces   +32 added lines, -64 removed lines patch added patch discarded remove patch
@@ -143,8 +143,7 @@  discard block
 block discarded – undo
143 143
         public function __construct(Database $db = null){
144 144
             if (is_object($db)){
145 145
                 $this->setDatabaseInstance($db);
146
-            }
147
-            else{
146
+            } else{
148 147
                 $obj = & get_instance();
149 148
         		if (isset($obj->database) && is_object($obj->database)){
150 149
                     /**
@@ -260,8 +259,7 @@  discard block
 block discarded – undo
260 259
                 $this->trigger('after_create', $insert_id);
261 260
 				//if the table doesn't have the auto increment field or sequence, the value of 0 will be returned 
262 261
 				return ! $insert_id ? true : $insert_id;
263
-            }
264
-            else
262
+            } else
265 263
             {
266 264
                 return FALSE;
267 265
             }
@@ -298,8 +296,7 @@  discard block
 block discarded – undo
298 296
                 $result = $this->_database->update($data, $escape);
299 297
                 $this->trigger('after_update', array($data, $result));
300 298
                 return $result;
301
-            }
302
-            else
299
+            } else
303 300
             {
304 301
                 return FALSE;
305 302
             }
@@ -322,8 +319,7 @@  discard block
 block discarded – undo
322 319
 				$result = $this->_database->update($data, $escape);
323 320
                 $this->trigger('after_update', array($data, $result));
324 321
                 return $result;
325
-            }
326
-            else
322
+            } else
327 323
             {
328 324
                 return FALSE;
329 325
             }
@@ -340,8 +336,7 @@  discard block
 block discarded – undo
340 336
                 if (is_array($args[1])){
341 337
                     $data = array_pop($args);
342 338
                 }
343
-            }
344
-            else if (count($args) == 3){
339
+            } else if (count($args) == 3){
345 340
                 if (is_array($args[2])){
346 341
                     $data = array_pop($args);
347 342
                 }
@@ -354,8 +349,7 @@  discard block
 block discarded – undo
354 349
 				$result = $this->_database->update($data);
355 350
                 $this->trigger('after_update', array($data, $result));
356 351
                 return $result;
357
-            }
358
-            else
352
+            } else
359 353
             {
360 354
                 return FALSE;
361 355
             }
@@ -385,8 +379,7 @@  discard block
 block discarded – undo
385 379
             {
386 380
                 $this->getQueryBuilder()->from($this->_table);	
387 381
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
388
-            }
389
-            else
382
+            } else
390 383
             {
391 384
                 $this->getQueryBuilder()->from($this->_table); 
392 385
 				$result = $this->_database->delete();
@@ -409,8 +402,7 @@  discard block
 block discarded – undo
409 402
             {
410 403
                 $this->getQueryBuilder()->from($this->_table);	
411 404
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
412
-            }
413
-            else
405
+            } else
414 406
             {
415 407
                 $this->getQueryBuilder()->from($this->_table); 
416 408
 				$result = $this->_database->delete();
@@ -431,8 +423,7 @@  discard block
 block discarded – undo
431 423
             {
432 424
                 $this->getQueryBuilder()->from($this->_table);	
433 425
 				$result = $this->_database->update(array( $this->soft_delete_key => TRUE ));
434
-            }
435
-            else
426
+            } else
436 427
             {
437 428
                 $this->getQueryBuilder()->from($this->_table); 
438 429
 				$result = $this->_database->delete();
@@ -494,8 +485,7 @@  discard block
 block discarded – undo
494 485
             if (count($args) == 2)
495 486
             {
496 487
                 list($key, $value) = $args;
497
-            }
498
-            else
488
+            } else
499 489
             {
500 490
                 $key = $this->primary_key;
501 491
                 $value = $args[0];
@@ -647,8 +637,7 @@  discard block
 block discarded – undo
647 637
             if (is_object($row))
648 638
             {
649 639
                 $row->created_at = date('Y-m-d H:i:s');
650
-            }
651
-            else
640
+            } else
652 641
             {
653 642
                 $row['created_at'] = date('Y-m-d H:i:s');
654 643
             }
@@ -660,8 +649,7 @@  discard block
 block discarded – undo
660 649
             if (is_object($row))
661 650
             {
662 651
                 $row->updated_at = date('Y-m-d H:i:s');
663
-            }
664
-            else
652
+            } else
665 653
             {
666 654
                 $row['updated_at'] = date('Y-m-d H:i:s');
667 655
             }
@@ -688,8 +676,7 @@  discard block
 block discarded – undo
688 676
                 if (is_array($row))
689 677
                 {
690 678
                     $row[$column] = unserialize($row[$column]);
691
-                }
692
-                else
679
+                } else
693 680
                 {
694 681
                     $row->$column = unserialize($row->$column);
695 682
                 }
@@ -709,8 +696,7 @@  discard block
 block discarded – undo
709 696
 					if (isset($row->$attr)){
710 697
 						unset($row->$attr);
711 698
 					}
712
-                }
713
-                else
699
+                } else
714 700
                 {
715 701
 					if (isset($row[$attr])){
716 702
 						unset($row[$attr]);
@@ -810,8 +796,7 @@  discard block
 block discarded – undo
810 796
                 {
811 797
                     $this->getQueryBuilder()->orderBy($key, $value);
812 798
                 }
813
-            }
814
-            else
799
+            } else
815 800
             {
816 801
                 $this->getQueryBuilder()->orderBy($criteria, $order);
817 802
             }
@@ -842,8 +827,7 @@  discard block
 block discarded – undo
842 827
                 {
843 828
                     $relationship = $value;
844 829
                     $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' );
845
-                }
846
-                else
830
+                } else
847 831
                 {
848 832
                     $relationship = $key;
849 833
                     $options = $value;
@@ -853,15 +837,13 @@  discard block
 block discarded – undo
853 837
                 {
854 838
                     if (is_object($this->loaderInstance)){
855 839
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
856
-                    }
857
-                    else{
840
+                    } else{
858 841
                         Loader::model($options['model'], $relationship . '_model');    
859 842
                     }
860 843
                     if (is_object($row))
861 844
                     {
862 845
                         $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']});
863
-                    }
864
-                    else
846
+                    } else
865 847
                     {
866 848
                         $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]);
867 849
                     }
@@ -881,8 +863,7 @@  discard block
 block discarded – undo
881 863
                 {
882 864
                     $relationship = $value;
883 865
                     $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' );
884
-                }
885
-                else
866
+                } else
886 867
                 {
887 868
                     $relationship = $key;
888 869
                     $options = $value;
@@ -892,15 +873,13 @@  discard block
 block discarded – undo
892 873
                 {
893 874
                     if (is_object($this->loaderInstance)){
894 875
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
895
-                    }
896
-                    else{
876
+                    } else{
897 877
                         Loader::model($options['model'], $relationship . '_model');    
898 878
                     }
899 879
                     if (is_object($row))
900 880
                     {
901 881
                         $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key});
902
-                    }
903
-                    else
882
+                    } else
904 883
                     {
905 884
                         $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]);
906 885
                     }
@@ -946,8 +925,7 @@  discard block
 block discarded – undo
946 925
                 $fv = null;
947 926
                 if (is_object($this->formValidationInstance)){
948 927
                     $fv = $this->formValidationInstance;
949
-                }
950
-                else{
928
+                } else{
951 929
                     Loader::library('FormValidation');
952 930
                     $fv = $this->formvalidation;
953 931
                     $this->setFormValidation($fv);
@@ -959,13 +937,11 @@  discard block
 block discarded – undo
959 937
                 if ($fv->run())
960 938
                 {
961 939
                     return $data;
962
-                }
963
-                else
940
+                } else
964 941
                 {
965 942
                     return FALSE;
966 943
                 }
967
-            }
968
-            else
944
+            } else
969 945
             {
970 946
                 return $data;
971 947
             }
@@ -982,14 +958,12 @@  discard block
 block discarded – undo
982 958
 				if (is_array($filter))
983 959
 				{
984 960
 					$this->getQueryBuilder()->in($field, $filter);
985
-				}
986
-				else
961
+				} else
987 962
 				{
988 963
 					if (is_int($field))
989 964
 					{
990 965
 						$this->getQueryBuilder()->where($filter);
991
-					}
992
-					else
966
+					} else
993 967
 					{
994 968
 						$this->getQueryBuilder()->where($field, $filter);
995 969
 					}
@@ -1006,33 +980,27 @@  discard block
 block discarded – undo
1006 980
             if (count($params) == 1 && is_array($params[0]))
1007 981
             {
1008 982
                 $this->_set_where_array($params[0]);
1009
-            }
1010
-            else if (count($params) == 1)
983
+            } else if (count($params) == 1)
1011 984
             {
1012 985
                 $this->getQueryBuilder()->where($params[0]);
1013
-            }
1014
-        	else if (count($params) == 2)
986
+            } else if (count($params) == 2)
1015 987
     		{
1016 988
                 if (is_array($params[1]))
1017 989
                 {
1018 990
                     $this->getQueryBuilder()->in($params[0], $params[1]);
1019
-                }
1020
-                else
991
+                } else
1021 992
                 {
1022 993
                     $this->getQueryBuilder()->where($params[0], $params[1]);
1023 994
                 }
1024
-    		}
1025
-    		else if (count($params) == 3)
995
+    		} else if (count($params) == 3)
1026 996
     		{
1027 997
     			$this->getQueryBuilder()->where($params[0], $params[1], $params[2]);
1028
-    		}
1029
-            else
998
+    		} else
1030 999
             {
1031 1000
                 if (is_array($params[1]))
1032 1001
                 {
1033 1002
                     $this->getQueryBuilder()->in($params[0], $params[1]);
1034
-                }
1035
-                else
1003
+                } else
1036 1004
                 {
1037 1005
                     $this->getQueryBuilder()->where($params[0], $params[1]);
1038 1006
                 }
Please login to merge, or discard this patch.
core/classes/Database.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -153,14 +153,12 @@  discard block
 block discarded – undo
153 153
             $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'");
154 154
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
155 155
             return true;
156
-          }
157
-          catch (PDOException $e){
156
+          } catch (PDOException $e){
158 157
             $this->logger->fatal($e->getMessage());
159 158
             show_error('Cannot connect to Database.');
160 159
             return false;
161 160
           }
162
-      }
163
-      else{
161
+      } else{
164 162
         show_error('Database configuration is not set.');
165 163
         return false;
166 164
       }
@@ -203,8 +201,7 @@  discard block
 block discarded – undo
203 201
       $query = $this->getAll(true);
204 202
       if ($returnSQLQueryOrResultType === true){
205 203
         return $query;
206
-      }
207
-      else{
204
+      } else{
208 205
         return $this->query($query, false, $returnSQLQueryOrResultType == 'array');
209 206
       }
210 207
     }
@@ -628,15 +625,13 @@  discard block
 block discarded – undo
628 625
       //if need return all result like list of record
629 626
       if (is_bool($all) && $all){
630 627
           $this->result = ($array === false) ? $pdoStatment->fetchAll(PDO::FETCH_OBJ) : $pdoStatment->fetchAll(PDO::FETCH_ASSOC);
631
-      }
632
-      else{
628
+      } else{
633 629
           $this->result = ($array === false) ? $pdoStatment->fetch(PDO::FETCH_OBJ) : $pdoStatment->fetch(PDO::FETCH_ASSOC);
634 630
       }
635 631
       //Sqlite and pgsql always return 0 when using rowCount()
636 632
       if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){
637 633
         $this->numRows = count($this->result);  
638
-      }
639
-      else{
634
+      } else{
640 635
         $this->numRows = $pdoStatment->rowCount(); 
641 636
       }
642 637
     }
@@ -650,8 +645,7 @@  discard block
 block discarded – undo
650 645
       if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){
651 646
         $this->result = true; //to test the result for the query like UPDATE, INSERT, DELETE
652 647
         $this->numRows = 1; //TODO use the correct method to get the exact affected row
653
-      }
654
-      else{
648
+      } else{
655 649
           $this->result = $pdoStatment->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
656 650
           $this->numRows = $pdoStatment->rowCount(); 
657 651
       }
@@ -776,8 +770,7 @@  discard block
 block discarded – undo
776 770
     protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){
777 771
       if ($logger !== null){
778 772
         $this->setLogger($logger);
779
-      }
780
-      else{
773
+      } else{
781 774
           $this->logger =& class_loader('Log', 'classes');
782 775
           $this->logger->setLogger('Library::Database');
783 776
       }
@@ -790,8 +783,7 @@  discard block
 block discarded – undo
790 783
 	protected function setQueryBuilderFromParamOrCreateNewInstance(DatabaseQueryBuilder $queryBuilder = null){
791 784
 	  if ($queryBuilder !== null){
792 785
       $this->setQueryBuilder($queryBuilder);
793
-	  }
794
-	  else{
786
+	  } else{
795 787
 		  $this->queryBuilder =& class_loader('DatabaseQueryBuilder', 'classes');
796 788
 	  }
797 789
 	}
Please login to merge, or discard this patch.
core/classes/DatabaseQueryBuilder.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -225,8 +225,7 @@  discard block
 block discarded – undo
225 225
       }
226 226
       if (empty($this->join)){
227 227
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
228
-      }
229
-      else{
228
+      } else{
230 229
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
231 230
       }
232 231
       return $this;
@@ -334,8 +333,7 @@  discard block
 block discarded – undo
334 333
       $whereStr = '';
335 334
       if (is_array($where)){
336 335
         $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape);
337
-      }
338
-      else{
336
+      } else{
339 337
         if (is_array($op)){
340 338
           $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape);
341 339
         } else {
@@ -585,8 +583,7 @@  discard block
 block discarded – undo
585 583
       }
586 584
       if (! is_null($limitEnd)){
587 585
         $this->limit = $limit . ', ' . $limitEnd;
588
-      }
589
-      else{
586
+      } else{
590 587
         $this->limit = $limit;
591 588
       }
592 589
       return $this;
@@ -601,8 +598,7 @@  discard block
 block discarded – undo
601 598
     public function orderBy($orderBy, $orderDir = ' ASC'){
602 599
       if (stristr($orderBy, ' ') || $orderBy == 'rand()'){
603 600
         $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy;
604
-      }
605
-      else{
601
+      } else{
606 602
         $this->orderBy = empty($this->orderBy) 
607 603
 						? ($orderBy . ' ' . strtoupper($orderDir)) 
608 604
 						: $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
@@ -618,8 +614,7 @@  discard block
 block discarded – undo
618 614
     public function groupBy($field){
619 615
       if (is_array($field)){
620 616
         $this->groupBy = implode(', ', $field);
621
-      }
622
-      else{
617
+      } else{
623 618
         $this->groupBy = $field;
624 619
       }
625 620
       return $this;
@@ -636,14 +631,12 @@  discard block
 block discarded – undo
636 631
     public function having($field, $op = null, $val = null, $escape = true){
637 632
       if (is_array($op)){
638 633
         $this->having = $this->getHavingStrIfOperatorIsArray($field, $op, $escape);
639
-      }
640
-      else if (! in_array($op, $this->operatorList)){
634
+      } else if (! in_array($op, $this->operatorList)){
641 635
         if (is_null($op)){
642 636
           $op = '';
643 637
         }
644 638
         $this->having = $field . ' > ' . ($this->escape($op, $escape));
645
-      }
646
-      else{
639
+      } else{
647 640
         if (is_null($val)){
648 641
           $val = '';
649 642
         }
Please login to merge, or discard this patch.