Passed
Push — master ( 2452cb...36c8a5 )
by RN
01:50
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/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
@@ -16,55 +16,55 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class InsertQueryBuilder extends QueryBuilder
18 18
 {
19
-    private function buildInsert($table, $obj){
19
+    private function buildInsert($table, $obj) {
20 20
         $qb = new QueryBuilder();
21 21
         $query = "INSERT INTO ".$table." (";
22
-        foreach($obj as $key => $val){
23
-            $query.= $qb->quote($key).", ";
22
+        foreach ($obj as $key => $val) {
23
+            $query .= $qb->quote($key).", ";
24 24
         }
25 25
 
26 26
         $query = rtrim($query, ", ");
27
-        $query.= ") VALUES ";
27
+        $query .= ") VALUES ";
28 28
 
29 29
         return $query;
30 30
     }
31 31
 
32
-    private function buildInsertPlaceholder($rows){
32
+    private function buildInsertPlaceholder($rows) {
33 33
         $ar = array();
34 34
         $query = "(";
35 35
 
36
-        foreach($rows as $key => $val){
36
+        foreach ($rows as $key => $val) {
37 37
             $ar[$key] = $val;
38
-            $query.= ":".$key.", ";
38
+            $query .= ":".$key.", ";
39 39
         }
40 40
 
41 41
         $query = rtrim($query, ", ");
42
-        $query.=") ";
42
+        $query .= ") ";
43 43
 
44 44
         return ['query' => $query, 'array' => $ar];
45 45
     }
46 46
 
47
-    private function buildInsertPlaceholders($rows){
47
+    private function buildInsertPlaceholders($rows) {
48 48
         $bindAr = array();
49 49
         $query = "";
50 50
 
51
-        foreach($rows as $i => $row){
52
-            $query.="(";
53
-            foreach($row as $key => $val){
54
-                $param = ":" . $key . $i;
55
-                $query.= $param.", ";
51
+        foreach ($rows as $i => $row) {
52
+            $query .= "(";
53
+            foreach ($row as $key => $val) {
54
+                $param = ":".$key.$i;
55
+                $query .= $param.", ";
56 56
                 $bindAr[$param] = $val;
57 57
             }
58 58
 
59 59
             $query = rtrim($query, ", ");
60
-            $query.="), ";
60
+            $query .= "), ";
61 61
         }
62 62
 
63 63
         $query = rtrim($query, ", ");
64 64
         return ['query' => $query, 'array' => $bindAr];
65 65
     }
66 66
 
67
-    private function checkMultipleInsert($rows = array()){
67
+    private function checkMultipleInsert($rows = array()) {
68 68
       return is_array($rows) && isset($rows[0]) && is_array($rows[0]);
69 69
     }
70 70
     /**
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
         $dataToBuild = $rows;
84 84
         $methodToCall = 'buildInsertPlaceholder';
85 85
 
86
-        if($this->checkMultipleInsert($rows)){
86
+        if ($this->checkMultipleInsert($rows)) {
87 87
             $dataToBuild = $rows[0];
88 88
             $methodToCall = 'buildInsertPlaceholders';
89 89
         }
90 90
 
91 91
         $query   = $this->buildInsert($table, $dataToBuild);
92 92
         $dataRet = $this->$methodToCall($rows);
93
-        $query.= $dataRet['query'];
93
+        $query .= $dataRet['query'];
94 94
         $bindAr = $dataRet['array'];
95 95
 
96
-        try{
96
+        try {
97 97
             $stmt = $db->prepare($this->queryPrefix($query));
98 98
 
99
-            if($this->checkMultipleInsert($rows)){
100
-                foreach($bindAr as $param => $val){
99
+            if ($this->checkMultipleInsert($rows)) {
100
+                foreach ($bindAr as $param => $val) {
101 101
                     $stmt->bindValue($param, $val);
102 102
                 }
103 103
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
             $stmt->execute($bindAr);
109 109
             return $db->lastInsertId();
110
-        } catch(Exception $e){
110
+        } catch (Exception $e) {
111 111
             throw new Exception($e->getMessage());
112 112
         }
113 113
     }
Please login to merge, or discard this patch.
src/Dolphin/Builders/UpdateQueryBuilder.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
      * @since v0.0.5
27 27
      */
28 28
     public function update(
29
-      $row,
30
-      $table,
31
-      $where,
32
-      $whereRaw,
33
-      $whereIn,
34
-      $whereNotIn,
35
-      $whereNull,
36
-      $whereNotNull
29
+        $row,
30
+        $table,
31
+        $where,
32
+        $whereRaw,
33
+        $whereIn,
34
+        $whereNotIn,
35
+        $whereNull,
36
+        $whereNotNull
37 37
     )
38 38
     {
39 39
         $wqb   = new WhereQueryBuilder();
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
         $query = "UPDATE ".$table." SET ";
41 41
         $ar    = array();
42 42
 
43
-        foreach($row as $key => $val){
43
+        foreach ($row as $key => $val) {
44 44
             $ar[':'.$key] = $val;
45
-            $query.= $this->quote($key)." =:".$key.",";
45
+            $query .= $this->quote($key)." =:".$key.",";
46 46
         }
47 47
 
48 48
         $query = rtrim($query, ",");
49 49
 
50
-        try{
50
+        try {
51 51
             $whereQuery = $wqb->buildAllWhereQuery(
52 52
                                 $where,
53 53
                                 $whereRaw,
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
                                 $whereNull,
57 57
                                 $whereNotNull
58 58
                             );
59
-            $query.= " ".join(" ", $whereQuery);
59
+            $query .= " ".join(" ", $whereQuery);
60 60
             $stmt = Connection::get()->prepare($this->queryPrefix($query));
61 61
             $stmt->execute($ar);
62
-        } catch(Exception $e){
62
+        } catch (Exception $e) {
63 63
             throw new Exception($e->getMessage());
64 64
         }
65 65
 
Please login to merge, or discard this patch.
src/Dolphin/Dolphin.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
             }
300 300
 
301 301
             if(count($this->results) ){
302
-              // now turn this stdClass object to the object type of calling model
303
-              $rows = $util->turnObjects($this->className, $this->results);
302
+                // now turn this stdClass object to the object type of calling model
303
+                $rows = $util->turnObjects($this->className, $this->results);
304 304
             }
305 305
             // Reset class variables
306 306
             $this->reset();
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
     public function update($row)
425 425
     {
426 426
         $result =  (new UpdateQueryBuilder())->update(
427
-          $row,
428
-          $this->table,
429
-          $this->where,
430
-          $this->whereRaw,
431
-          $this->whereIn,
432
-          $this->whereNotIn,
433
-          $this->whereNull,
434
-          $this->whereNotNull
427
+            $row,
428
+            $this->table,
429
+            $this->where,
430
+            $this->whereRaw,
431
+            $this->whereIn,
432
+            $this->whereNotIn,
433
+            $this->whereNull,
434
+            $this->whereNotNull
435 435
         );
436 436
 
437 437
         $this->reset();
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
     public function delete()
471 471
     {
472 472
         $result =  (new DeleteQueryBuilder())->delete(
473
-          $this->table,
474
-          $this->where,
475
-          $this->whereRaw,
476
-          $this->whereIn,
477
-          $this->whereNotIn,
478
-          $this->whereNull,
479
-          $this->whereNotNull
473
+            $this->table,
474
+            $this->where,
475
+            $this->whereRaw,
476
+            $this->whereIn,
477
+            $this->whereNotIn,
478
+            $this->whereNull,
479
+            $this->whereNotNull
480 480
         );
481 481
 
482 482
         $this->reset();
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
     protected $offset;
75 75
     protected $results;
76 76
 
77
-    private function getFields(array $args, bool $quote = true){
77
+    private function getFields(array $args, bool $quote = true) {
78 78
         return (new QueryBuilder())->getFields($args, $quote);
79 79
     }
80 80
 
81
-    private function validateArgsCount($noOfArgs){
82
-        if($noOfArgs<2 || $noOfArgs >3){
81
+    private function validateArgsCount($noOfArgs) {
82
+        if ($noOfArgs < 2 || $noOfArgs > 3) {
83 83
             throw new Exception('Where parameter contains invalid number of parameters', 1);
84 84
         }
85 85
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
         $this->validateArgsCount($noOfArgs);
142 142
 
143
-        if($noOfArgs===2){
143
+        if ($noOfArgs === 2) {
144 144
             $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]);
145 145
             return $this;
146 146
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     protected function buildQuery()
227 227
     {
228
-        $query  = (new QueryBuilder())->buildQuery([
228
+        $query = (new QueryBuilder())->buildQuery([
229 229
             'table' => $this->table,
230 230
             'fields' => $this->fields,
231 231
             'join' => $this->join,
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 
285 285
             if ($fetchRows == 'first') {
286 286
                 $this->results = $stmt->fetch(\PDO::FETCH_OBJ);
287
-            } else{
287
+            } else {
288 288
                 $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
289 289
             }
290 290
 
291
-            if(count($this->results) ){
291
+            if (count($this->results)) {
292 292
               // now turn this stdClass object to the object type of calling model
293 293
               $rows = $util->turnObjects($this->className, $this->results);
294 294
             }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
         $this->where('id', $id);
360 360
         $row = $this->first();
361 361
 
362
-        if($row == null ){
362
+        if ($row == null) {
363 363
             throw new Exception("The record does not exists!");
364 364
         }
365 365
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function update($row)
400 400
     {
401
-        $result =  (new UpdateQueryBuilder())->update(
401
+        $result = (new UpdateQueryBuilder())->update(
402 402
           $row,
403 403
           $this->table,
404 404
           $this->where,
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
         $qb = new QueryBuilder();
427 427
         $query = "TRUNCATE ".$this->table;
428 428
 
429
-        try{
429
+        try {
430 430
             Connection::get()->query($qb->queryPrefix($query));
431
-        } catch(Exception $e){
431
+        } catch (Exception $e) {
432 432
             throw new Exception($e->getMessage());
433 433
         }
434 434
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
      */
445 445
     public function delete()
446 446
     {
447
-        $result =  (new DeleteQueryBuilder())->delete(
447
+        $result = (new DeleteQueryBuilder())->delete(
448 448
           $this->table,
449 449
           $this->where,
450 450
           $this->whereRaw,
Please login to merge, or discard this patch.
src/Dolphin/Builders/DeleteQueryBuilder.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
      * @since v0.0.5
27 27
      */
28 28
     public function delete(
29
-      $table,
30
-      $where,
31
-      $whereRaw,
32
-      $whereIn,
33
-      $whereNotIn,
34
-      $whereNull,
35
-      $whereNotNull
29
+        $table,
30
+        $where,
31
+        $whereRaw,
32
+        $whereIn,
33
+        $whereNotIn,
34
+        $whereNull,
35
+        $whereNotNull
36 36
     )
37 37
     {
38 38
         $wqb = new WhereQueryBuilder();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $wqb = new WhereQueryBuilder();
39 39
         $query = "DELETE FROM ".$table;
40 40
 
41
-        try{
41
+        try {
42 42
             $whereQuery = $wqb->buildAllWhereQuery(
43 43
                                     $where,
44 44
                                     $whereRaw,
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
                                     $whereNull,
48 48
                                     $whereNotNull
49 49
                                 );
50
-            $query.= " ".join(" ", $whereQuery);
50
+            $query .= " ".join(" ", $whereQuery);
51 51
             Connection::get()->query($this->queryPrefix($query));
52
-        } catch(Exception $e){
52
+        } catch (Exception $e) {
53 53
             throw new Exception($e->getMessage());
54 54
         }
55 55
 
Please login to merge, or discard this patch.