Passed
Push — 1.0.0-dev ( 97be91...7decce )
by nguereza
09:55
created
core/classes/Database.php 1 patch
Braces   +27 added lines, -54 removed lines patch added patch discarded remove patch
@@ -204,14 +204,12 @@  discard block
 block discarded – undo
204 204
             $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'");
205 205
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
206 206
             return true;
207
-          }
208
-          catch (PDOException $e){
207
+          } catch (PDOException $e){
209 208
             $this->logger->fatal($e->getMessage());
210 209
             show_error('Cannot connect to Database.');
211 210
             return false;
212 211
           }
213
-      }
214
-      else{
212
+      } else{
215 213
         show_error('Database configuration is not set.');
216 214
         return false;
217 215
       }
@@ -229,8 +227,7 @@  discard block
 block discarded – undo
229 227
           $froms .= $this->prefix . $key . ', ';
230 228
         }
231 229
         $this->from = rtrim($froms, ', ');
232
-      }
233
-      else{
230
+      } else{
234 231
         $this->from = $this->prefix . $table;
235 232
       }
236 233
       return $this;
@@ -336,8 +333,7 @@  discard block
 block discarded – undo
336 333
       }
337 334
       if (empty($this->join)){
338 335
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
339
-      }
340
-      else{
336
+      } else{
341 337
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
342 338
       }
343 339
       return $this;
@@ -408,8 +404,7 @@  discard block
 block discarded – undo
408 404
         foreach($field as $f){
409 405
         	$this->whereIsNull($f, $andOr);
410 406
         }
411
-      }
412
-      else{
407
+      } else{
413 408
            $this->setWhereStr($field.' IS NULL ', $andOr);
414 409
       }
415 410
       return $this;
@@ -426,8 +421,7 @@  discard block
 block discarded – undo
426 421
         foreach($field as $f){
427 422
           $this->whereIsNotNull($f, $andOr);
428 423
         }
429
-      }
430
-      else{
424
+      } else{
431 425
           $this->setWhereStr($field.' IS NOT NULL ', $andOr);
432 426
       }
433 427
       return $this;
@@ -447,8 +441,7 @@  discard block
 block discarded – undo
447 441
       $whereStr = '';
448 442
       if (is_array($where)){
449 443
         $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape);
450
-      }
451
-      else{
444
+      } else{
452 445
         if(is_array($op)){
453 446
           $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape);
454 447
         } else {
@@ -496,12 +489,10 @@  discard block
 block discarded – undo
496 489
     public function groupStart($type = '', $andOr = ' AND'){
497 490
       if (empty($this->where)){
498 491
         $this->where = $type . ' (';
499
-      }
500
-      else{
492
+      } else{
501 493
           if(substr($this->where, -1) == '('){
502 494
             $this->where .= $type . ' (';
503
-          }
504
-          else{
495
+          } else{
505 496
           	$this->where .= $andOr . ' ' . $type . ' (';
506 497
           }
507 498
       }
@@ -700,8 +691,7 @@  discard block
 block discarded – undo
700 691
       }
701 692
       if (! is_null($limitEnd)){
702 693
         $this->limit = $limit . ', ' . $limitEnd;
703
-      }
704
-      else{
694
+      } else{
705 695
         $this->limit = $limit;
706 696
       }
707 697
       return $this;
@@ -716,8 +706,7 @@  discard block
 block discarded – undo
716 706
     public function orderBy($orderBy, $orderDir = ' ASC'){
717 707
         if(stristr($orderBy, ' ') || $orderBy == 'rand()'){
718 708
           $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy;
719
-        }
720
-        else{
709
+        } else{
721 710
           $this->orderBy = empty($this->orderBy) ? ($orderBy . ' ' 
722 711
                             . strtoupper($orderDir)) : $this->orderBy 
723 712
                             . ', ' . $orderBy . ' ' . strtoupper($orderDir);
@@ -733,8 +722,7 @@  discard block
 block discarded – undo
733 722
     public function groupBy($field){
734 723
       if(is_array($field)){
735 724
         $this->groupBy = implode(', ', $field);
736
-      }
737
-      else{
725
+      } else{
738 726
         $this->groupBy = $field;
739 727
       }
740 728
       return $this;
@@ -761,14 +749,12 @@  discard block
 block discarded – undo
761 749
   	      }
762 750
       	}
763 751
         $this->having = $w;
764
-      }
765
-      else if (! in_array($op, $this->operatorList)){
752
+      } else if (! in_array($op, $this->operatorList)){
766 753
         if(is_null($op)){
767 754
           $op = '';
768 755
         }
769 756
         $this->having = $field . ' > ' . ($this->escape($op, $escape));
770
-      }
771
-      else{
757
+      } else{
772 758
         if(is_null($val)){
773 759
           $val = '';
774 760
         }
@@ -813,8 +799,7 @@  discard block
 block discarded – undo
813 799
       $query = $this->getAll(true);
814 800
       if($returnSQLQueryOrResultType === true){
815 801
         return $query;
816
-      }
817
-      else{
802
+      } else{
818 803
         return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) );
819 804
       }
820 805
     }
@@ -853,8 +838,7 @@  discard block
 block discarded – undo
853 838
 	  
854 839
 	   if($returnSQLQueryOrResultType === true){
855 840
       	return $query;
856
-      }
857
-      else{
841
+      } else{
858 842
     	   return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) );
859 843
       }
860 844
     }
@@ -887,8 +871,7 @@  discard block
 block discarded – undo
887 871
         }
888 872
         $this->insertId = $this->pdo->lastInsertId();
889 873
         return $this->insertId();
890
-      }
891
-      else{
874
+      } else{
892 875
 		  return false;
893 876
       }
894 877
     }
@@ -984,8 +967,7 @@  discard block
 block discarded – undo
984 967
 	  
985 968
       if ($dbCacheStatus && $isSqlSELECTQuery){
986 969
           $cacheContent = $this->getCacheContentForQuery($query, $all, $array);  
987
-      }
988
-      else{
970
+      } else{
989 971
 		      $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database');
990 972
       }
991 973
      
@@ -1001,8 +983,7 @@  discard block
 block discarded – undo
1001 983
                                             $this->temporaryCacheTtl
1002 984
                                           );
1003 985
         }
1004
-      }
1005
-      else if ((! $cacheContent && !$isSqlSELECTQuery) || ($cacheContent && !$isSqlSELECTQuery)){
986
+      } else if ((! $cacheContent && !$isSqlSELECTQuery) || ($cacheContent && !$isSqlSELECTQuery)){
1006 987
     		$sqlQuery = $this->runSqlQuery($query, $all, $array);
1007 988
     		if($sqlQuery){
1008 989
           $this->setQueryResultForNonSelect($sqlQuery, $all, $array);
@@ -1010,8 +991,7 @@  discard block
 block discarded – undo
1010 991
         if (! $this->result){
1011 992
           $this->setQueryError();
1012 993
         }
1013
-      }
1014
-      else{
994
+      } else{
1015 995
         $this->logger->info('The result for query [' .$this->query. '] already cached use it');
1016 996
         $this->result = $cacheContent;
1017 997
 	     	$this->numRows = count($this->result);
@@ -1204,8 +1184,7 @@  discard block
 block discarded – undo
1204 1184
     protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){
1205 1185
       if($logger !== null){
1206 1186
         $this->logger = $logger;
1207
-      }
1208
-      else{
1187
+      } else{
1209 1188
           $this->logger =& class_loader('Log', 'classes');
1210 1189
           $this->logger->setLogger('Library::Database');
1211 1190
       }
@@ -1331,8 +1310,7 @@  discard block
 block discarded – undo
1331 1310
             $op = '';
1332 1311
           }
1333 1312
           $w = $type . $where . ' = ' . ($this->escape($op, $escape));
1334
-        }
1335
-        else{
1313
+        } else{
1336 1314
           if(is_null($val)){
1337 1315
             $val = '';
1338 1316
           }
@@ -1349,12 +1327,10 @@  discard block
 block discarded – undo
1349 1327
       protected function setWhereStr($whereStr, $andOr = 'AND'){
1350 1328
         if (empty($this->where)){
1351 1329
           $this->where = $whereStr;
1352
-        }
1353
-        else{
1330
+        } else{
1354 1331
           if(substr($this->where, -1) == '('){
1355 1332
             $this->where = $this->where . ' ' . $whereStr;
1356
-          }
1357
-          else{
1333
+          } else{
1358 1334
             $this->where = $this->where . ' '.$andOr.' ' . $whereStr;
1359 1335
           }
1360 1336
         }
@@ -1430,15 +1406,13 @@  discard block
 block discarded – undo
1430 1406
       //if need return all result like list of record
1431 1407
       if ($all){
1432 1408
           $this->result = ($array === false) ? $pdoStatment->fetchAll(PDO::FETCH_OBJ) : $pdoStatment->fetchAll(PDO::FETCH_ASSOC);
1433
-      }
1434
-      else{
1409
+      } else{
1435 1410
           $this->result = ($array === false) ? $pdoStatment->fetch(PDO::FETCH_OBJ) : $pdoStatment->fetch(PDO::FETCH_ASSOC);
1436 1411
       }
1437 1412
       //Sqlite and pgsql always return 0 when using rowCount()
1438 1413
       if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1439 1414
         $this->numRows = count($this->result);  
1440
-      }
1441
-      else{
1415
+      } else{
1442 1416
         $this->numRows = $pdoStatment->rowCount(); 
1443 1417
       }
1444 1418
     }
@@ -1452,8 +1426,7 @@  discard block
 block discarded – undo
1452 1426
       if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1453 1427
         $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE
1454 1428
         $this->numRows = 1;  
1455
-      }
1456
-      else{
1429
+      } else{
1457 1430
           $this->result = $pdoStatment->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
1458 1431
           $this->numRows = $pdoStatment->rowCount(); 
1459 1432
       }
Please login to merge, or discard this patch.
core/libraries/FormValidation.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -220,8 +220,7 @@  discard block
 block discarded – undo
220 220
                 //first check for CSRF
221 221
                 if ((get_config('csrf_enable', false) || $this->enableCsrfCheck) && ! Security::validateCSRF()){
222 222
                     show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
223
-                }
224
-                else{
223
+                } else{
225 224
                     $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
226 225
                 }
227 226
             }
@@ -231,8 +230,7 @@  discard block
 block discarded – undo
231 230
             foreach ($this->getData() as $inputName => $inputVal) {
232 231
     			if(is_array($this->data[$inputName])){
233 232
     				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
234
-    			}
235
-    			else{
233
+    			} else{
236 234
     				$this->data[$inputName] = trim($this->data[$inputName]);
237 235
     			}
238 236
 
@@ -600,8 +598,7 @@  discard block
 block discarded – undo
600 598
                 if ($inputVal == '' && $callbackReturn == true) {
601 599
                     $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
602 600
                 }
603
-            } 
604
-			else if($inputVal == '') {
601
+            } else if($inputVal == '') {
605 602
 				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
606 603
             }
607 604
         }
@@ -660,8 +657,7 @@  discard block
 block discarded – undo
660 657
                         $this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual))));
661 658
                         continue;
662 659
                     }
663
-                } 
664
-				else{
660
+                } else{
665 661
                     if ($inputVal == $doNotEqual) {
666 662
                         $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
667 663
                         continue;
Please login to merge, or discard this patch.