Passed
Push — master ( dd8496...f181bd )
by RN
01:45
created
src/Dolphin/Config/Credentials.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         $dbCredentials = require('database.php');
16 16
         $var = $arguments[0];
17 17
 
18
-        if(array_key_exists($var, $dbCredentials)){
18
+        if (array_key_exists($var, $dbCredentials)) {
19 19
             return $dbCredentials[$var];
20 20
         }
21 21
 
Please login to merge, or discard this patch.
src/Dolphin/ORM.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
     public function __call($method, $parameters)
28 28
     {
29
-        if($method== 'asArray'){
29
+        if ($method == 'asArray') {
30 30
             // $obj = new Utils();
31 31
         }
32 32
     }
Please login to merge, or discard this patch.
src/Dolphin/Utils/Utils.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,16 +50,16 @@
 block discarded – undo
50 50
         return $destination;
51 51
     }
52 52
     
53
-     /**
54
-     * Turn the stadClass object to the type of calling Model
55
-     *
56
-     * @param String $destination
57
-     * @param Object $sourceObject
58
-     * @return Object $destination
59
-     *
60
-     * @author RN Kushwaha <[email protected]>
61
-     * @since v0.0.5
62
-     */
53
+        /**
54
+         * Turn the stadClass object to the type of calling Model
55
+         *
56
+         * @param String $destination
57
+         * @param Object $sourceObject
58
+         * @return Object $destination
59
+         *
60
+         * @author RN Kushwaha <[email protected]>
61
+         * @since v0.0.5
62
+         */
63 63
     public function turnObjects($destination, $data)
64 64
     {
65 65
         $destination = new $destination();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function turnObject($destination, $sourceObject)
29 29
     {
30 30
         $destination = new $destination();
31
-        if(!is_object($sourceObject)){
31
+        if (!is_object($sourceObject)) {
32 32
             return $destination;
33 33
         }
34 34
         
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             if ($destinationReflection->hasProperty($name)) {
45 45
                 $propDest = $destinationReflection->getProperty($name);
46 46
                 $propDest->setAccessible(true);
47
-                $propDest->setValue($destination,$value);
47
+                $propDest->setValue($destination, $value);
48 48
             } else {
49 49
                 $destination->$name = $value;
50 50
             }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function turnObjects($destination, $data)
67 67
     {
68 68
         $destination = new $destination();
69
-        if(count($data)){
69
+        if (count($data)) {
70 70
             $destination->data = json_decode(json_encode($data, true));
71 71
         }
72 72
 
Please login to merge, or discard this patch.
src/Dolphin/Parsers/WhereQueryParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 class WhereQueryParser
14 14
 {
15 15
 
16
-    protected function prepareArrayForWhere($bindKey, $bindVal = null){
16
+    protected function prepareArrayForWhere($bindKey, $bindVal = null) {
17 17
         $ar = $conditionAr = array();
18 18
         // expecting a string like 'status = :status'
19 19
         if ($this->checkWherePrepareUsed($bindKey)) {
Please login to merge, or discard this patch.
src/Dolphin/Save.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@
 block discarded – undo
23 23
     }
24 24
 
25 25
     public function buildQueryStrSingleFromArr($row = array()){
26
-      $ar = [];
27
-      $query = "UPDATE ".$this->table." SET ";
28
-      foreach($row as $key => $val){
29
-          $ar[':'.$key] = $val;
30
-          if($key == 'id') continue;
31
-          $query.= $this->qb->quote($key)." =:".$key.",";
32
-      }
33
-      $query = rtrim($query, ",");
26
+        $ar = [];
27
+        $query = "UPDATE ".$this->table." SET ";
28
+        foreach($row as $key => $val){
29
+            $ar[':'.$key] = $val;
30
+            if($key == 'id') continue;
31
+            $query.= $this->qb->quote($key)." =:".$key.",";
32
+        }
33
+        $query = rtrim($query, ",");
34 34
 
35
-      return ['ar' => $ar, 'query' => $query];
35
+        return ['ar' => $ar, 'query' => $query];
36 36
     }
37 37
     public function createQuery($row){
38 38
         $ar = [];
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,33 +22,33 @@  discard block
 block discarded – undo
22 22
         $this->qb = new QueryBuilder();
23 23
     }
24 24
 
25
-    public function buildQueryStrSingleFromArr($row = array()){
25
+    public function buildQueryStrSingleFromArr($row = array()) {
26 26
       $ar = [];
27 27
       $query = "UPDATE ".$this->table." SET ";
28
-      foreach($row as $key => $val){
28
+      foreach ($row as $key => $val) {
29 29
           $ar[':'.$key] = $val;
30
-          if($key == 'id') continue;
31
-          $query.= $this->qb->quote($key)." =:".$key.",";
30
+          if ($key == 'id') continue;
31
+          $query .= $this->qb->quote($key)." =:".$key.",";
32 32
       }
33 33
       $query = rtrim($query, ",");
34 34
 
35 35
       return ['ar' => $ar, 'query' => $query];
36 36
     }
37
-    public function createQuery($row){
37
+    public function createQuery($row) {
38 38
         $ar = [];
39
-        if(isset($row) && isset($row->id) && $row->id > 0 ){
39
+        if (isset($row) && isset($row->id) && $row->id > 0) {
40 40
             $mixedData = $this->buildQueryStrSingleFromArr($row);
41
-            $query= $mixedData['query']." WHERE ".$this->qb->quote('id')."=:id";
41
+            $query = $mixedData['query']." WHERE ".$this->qb->quote('id')."=:id";
42 42
 
43 43
             return ['query' => $query, 'data' => $mixedData['ar']];
44 44
         }
45 45
 
46 46
         $queryVal = '';
47 47
         $query = "INSERT INTO ".$this->table." (";
48
-        foreach($row as $key => $val){
49
-            $query.= $this->qb->quote($key).", ";
48
+        foreach ($row as $key => $val) {
49
+            $query .= $this->qb->quote($key).", ";
50 50
             $ar[$key] = $val;
51
-            $queryVal.= ":".$key.", ";
51
+            $queryVal .= ":".$key.", ";
52 52
         }
53 53
 
54 54
         $query = rtrim($query, ", ").") VALUES (".$queryVal.rtrim($query, ", ").") ";
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 
74 74
         list($query, $data) = $this->createQuery($row);
75 75
 
76
-        try{
76
+        try {
77 77
             $stmt = Connection::get()->prepare($this->qb->queryPrefix($query));
78 78
             $stmt->execute($data);
79
-        } catch(Exception $e){
79
+        } catch (Exception $e) {
80 80
             throw new Exception($e->getMessage());
81 81
         }
82 82
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@
 block discarded – undo
27 27
       $query = "UPDATE ".$this->table." SET ";
28 28
       foreach($row as $key => $val){
29 29
           $ar[':'.$key] = $val;
30
-          if($key == 'id') continue;
30
+          if($key == 'id') {
31
+              continue;
32
+          }
31 33
           $query.= $this->qb->quote($key)." =:".$key.",";
32 34
       }
33 35
       $query = rtrim($query, ",");
Please login to merge, or discard this patch.
src/Dolphin/Builders/QueryBuilder.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -78,21 +78,21 @@
 block discarded – undo
78 78
     }
79 79
 
80 80
     private function buildLimitQuery($limit, $offset, $query = array()){
81
-      $limitQuery = [];
82
-      if (!empty($limit)) {
83
-          $query[] = 'LIMIT';
81
+        $limitQuery = [];
82
+        if (!empty($limit)) {
83
+            $query[] = 'LIMIT';
84 84
 
85
-          if (!empty($offset)) {
86
-              $query[] = $offset.',';
87
-          }
85
+            if (!empty($offset)) {
86
+                $query[] = $offset.',';
87
+            }
88 88
 
89
-          $query[] = $limit;
90
-      }
89
+            $query[] = $limit;
90
+        }
91 91
 
92
-      if (count($limitQuery)) {
93
-          $query = array_merge($query, $limitQuery);
94
-      }
95
-      return $query;
92
+        if (count($limitQuery)) {
93
+            $query = array_merge($query, $limitQuery);
94
+        }
95
+        return $query;
96 96
     }
97 97
 
98 98
     public function buildQuery(array $params)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         return "'".$field."'";
69 69
     }
70 70
 
71
-    private function getQueryFields($fields, $tbl){
71
+    private function getQueryFields($fields, $tbl) {
72 72
         $startQuery = join(', ', $fields);
73 73
         if (empty($fields)) {
74 74
             $startQuery = $this->quote($tbl).'.*';
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         return $startQuery;
78 78
     }
79 79
 
80
-    private function buildLimitQuery($limit, $offset, $query = array()){
80
+    private function buildLimitQuery($limit, $offset, $query = array()) {
81 81
       $limitQuery = [];
82 82
       if (!empty($limit)) {
83 83
           $query[] = 'LIMIT';
Please login to merge, or discard this patch.
src/Dolphin/Builders/InsertQueryBuilder.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
     }
67 67
 
68 68
     private function checkMultipleInsert($rows = array()){
69
-      return is_array($rows) && isset($rows[0]) && is_array($rows[0]);
69
+        return is_array($rows) && isset($rows[0]) && is_array($rows[0]);
70 70
     }
71 71
     /**
72 72
      * It inserts the new rows
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -17,55 +17,55 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class InsertQueryBuilder extends QueryBuilder
19 19
 {
20
-    public function buildInsert($table, $obj){
20
+    public function buildInsert($table, $obj) {
21 21
         $qb = new QueryBuilder();
22 22
         $query = "INSERT INTO ".$table." (";
23
-        foreach($obj as $key => $val){
24
-            $query.= $qb->quote($key).", ";
23
+        foreach ($obj as $key => $val) {
24
+            $query .= $qb->quote($key).", ";
25 25
         }
26 26
 
27 27
         $query = rtrim($query, ", ");
28
-        $query.= ") VALUES ";
28
+        $query .= ") VALUES ";
29 29
 
30 30
         return $query;
31 31
     }
32 32
 
33
-    public function buildInsertPlaceholder($rows){
33
+    public function buildInsertPlaceholder($rows) {
34 34
         $ar = array();
35 35
         $query = "(";
36 36
 
37
-        foreach($rows as $key => $val){
37
+        foreach ($rows as $key => $val) {
38 38
             $ar[$key] = $val;
39
-            $query.= ":".$key.", ";
39
+            $query .= ":".$key.", ";
40 40
         }
41 41
 
42 42
         $query = rtrim($query, ", ");
43
-        $query.=") ";
43
+        $query .= ") ";
44 44
 
45 45
         return ['query' => $query, 'array' => $ar];
46 46
     }
47 47
 
48
-    public function buildInsertPlaceholders($rows){
48
+    public function buildInsertPlaceholders($rows) {
49 49
         $bindAr = array();
50 50
         $query = "";
51 51
 
52
-        foreach($rows as $i => $row){
53
-            $query.="(";
54
-            foreach($row as $key => $val){
55
-                $param = ":" . $key . $i;
56
-                $query.= $param.", ";
52
+        foreach ($rows as $i => $row) {
53
+            $query .= "(";
54
+            foreach ($row as $key => $val) {
55
+                $param = ":".$key.$i;
56
+                $query .= $param.", ";
57 57
                 $bindAr[$param] = $val;
58 58
             }
59 59
 
60 60
             $query = rtrim($query, ", ");
61
-            $query.="), ";
61
+            $query .= "), ";
62 62
         }
63 63
 
64 64
         $query = rtrim($query, ", ");
65 65
         return ['query' => $query, 'array' => $bindAr];
66 66
     }
67 67
 
68
-    private function checkMultipleInsert($rows = array()){
68
+    private function checkMultipleInsert($rows = array()) {
69 69
       return is_array($rows) && isset($rows[0]) && is_array($rows[0]);
70 70
     }
71 71
     /**
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
         $dataToBuild = $rows;
86 86
         $methodToCall = 'buildInsertPlaceholder';
87 87
 
88
-        if($this->checkMultipleInsert($rows)){
88
+        if ($this->checkMultipleInsert($rows)) {
89 89
             $dataToBuild = $rows[0];
90 90
             $methodToCall = 'buildInsertPlaceholders';
91 91
         }
92 92
 
93 93
         $query   = $this->buildInsert($table, $dataToBuild);
94 94
         $dataRet = $this->$methodToCall($rows);
95
-        $query.= $dataRet['query'];
95
+        $query .= $dataRet['query'];
96 96
         $bindAr = $dataRet['array'];
97 97
 
98
-        try{
98
+        try {
99 99
             $stmt = $db->prepare($qb->queryPrefix($query));
100 100
 
101
-            if($this->checkMultipleInsert($rows)){
102
-                foreach($bindAr as $param => $val){
101
+            if ($this->checkMultipleInsert($rows)) {
102
+                foreach ($bindAr as $param => $val) {
103 103
                     $stmt->bindValue($param, $val);
104 104
                 }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
             $stmt->execute($bindAr);
111 111
             return $db->lastInsertId();
112
-        } catch(Exception $e){
112
+        } catch (Exception $e) {
113 113
             throw new Exception($e->getMessage());
114 114
         }
115 115
     }
Please login to merge, or discard this patch.
src/Dolphin/Dolphin.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -290,8 +290,8 @@
 block discarded – undo
290 290
             }
291 291
 
292 292
             if(count($this->results) ){
293
-              // now turn this stdClass object to the object type of calling model
294
-              $rows = $util->turnObjects($this->className, $this->results);
293
+                // now turn this stdClass object to the object type of calling model
294
+                $rows = $util->turnObjects($this->className, $this->results);
295 295
             }
296 296
             // Reset class variables
297 297
             $this->reset();
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     protected $offset;
73 73
     protected $results;
74 74
 
75
-    private function getFields(array $args, bool $quote = true){
75
+    private function getFields(array $args, bool $quote = true) {
76 76
         $fldAr = array();
77 77
         $qb = new QueryBuilder();
78 78
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
         return $fldAr;
86 86
     }
87 87
 
88
-    private function validateArgsCount($noOfArgs){
89
-        if($noOfArgs<2 || $noOfArgs >3){
88
+    private function validateArgsCount($noOfArgs) {
89
+        if ($noOfArgs < 2 || $noOfArgs > 3) {
90 90
             throw new Exception('Where parameter contains invalid number of parameters', 1);
91 91
         }
92 92
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
         $this->validateArgsCount($noOfArgs);
149 149
 
150
-        if($noOfArgs===2){
150
+        if ($noOfArgs === 2) {
151 151
             $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]);
152 152
             return $this;
153 153
         }
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 
294 294
             if ($fetchRows == 'first') {
295 295
                 $this->results = $stmt->fetch(\PDO::FETCH_OBJ);
296
-            } else{
296
+            } else {
297 297
                 $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
298 298
             }
299 299
 
300
-            if(count($this->results) ){
300
+            if (count($this->results)) {
301 301
               // now turn this stdClass object to the object type of calling model
302 302
               $rows = $util->turnObjects($this->className, $this->results);
303 303
             }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
         $row = $this->first();
385 385
 
386
-        if($row == null ){
386
+        if ($row == null) {
387 387
             throw new Exception("The record does not exists!");
388 388
         }
389 389
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
         $qb = new QueryBuilder();
412 412
         $query = "TRUNCATE ".$this->table;
413 413
 
414
-        try{
414
+        try {
415 415
             Connection::get()->query($qb->queryPrefix($query));
416
-        } catch(Exception $e){
416
+        } catch (Exception $e) {
417 417
             throw new Exception($e->getMessage());
418 418
         }
419 419
 
@@ -449,14 +449,14 @@  discard block
 block discarded – undo
449 449
         $query = "UPDATE ".$this->table." SET ";
450 450
         $ar    = array();
451 451
 
452
-        foreach($row as $key => $val){
452
+        foreach ($row as $key => $val) {
453 453
             $ar[':'.$key] = $val;
454
-            $query.= $qb->quote($key)." =:".$key.",";
454
+            $query .= $qb->quote($key)." =:".$key.",";
455 455
         }
456 456
 
457 457
         $query = rtrim($query, ",");
458 458
 
459
-        try{
459
+        try {
460 460
             $whereQuery = $wqb->buildAllWhereQuery(
461 461
                                 $this->where,
462 462
                                 $this->whereRaw,
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
                                 $this->whereNull,
466 466
                                 $this->whereNotNull
467 467
                             );
468
-            $query.= " ".join(" ", $whereQuery);
468
+            $query .= " ".join(" ", $whereQuery);
469 469
             $stmt = Connection::get()->prepare($qb->queryPrefix($query));
470 470
             $stmt->execute($ar);
471 471
             $this->reset();
472
-        } catch(Exception $e){
472
+        } catch (Exception $e) {
473 473
             throw new Exception($e->getMessage());
474 474
         }
475 475
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         $wqb = new WhereQueryBuilder();
490 490
         $query = "DELETE FROM ".$this->table;
491 491
 
492
-        try{
492
+        try {
493 493
             $whereQuery = $wqb->buildAllWhereQuery(
494 494
                                     $this->where,
495 495
                                     $this->whereRaw,
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
                                     $this->whereNull,
499 499
                                     $this->whereNotNull
500 500
                                 );
501
-            $query.= " ".join(" ", $whereQuery);
501
+            $query .= " ".join(" ", $whereQuery);
502 502
             Connection::get()->query($qb->queryPrefix($query));
503 503
             $this->reset();
504
-        } catch(Exception $e){
504
+        } catch (Exception $e) {
505 505
             throw new Exception($e->getMessage());
506 506
         }
507 507
 
Please login to merge, or discard this patch.
src/Dolphin/Builders/WhereQueryBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 {
18 18
     private $qb;
19 19
 
20
-    public function __construct(){
20
+    public function __construct() {
21 21
         $this->qb = new QueryBuilder();
22 22
     }
23 23
 
24
-    private function emptyConditionsResponse($conditions = array()){
24
+    private function emptyConditionsResponse($conditions = array()) {
25 25
         if (!count($conditions)) {
26 26
             return array();
27 27
         }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         foreach ($conditions as $where) {
54 54
             $sign = '=';
55
-            if(count($where)==3) {
55
+            if (count($where) == 3) {
56 56
                 $sign = $where[1];
57 57
             }
58 58
             if ($firstTime) {
Please login to merge, or discard this patch.