Passed
Push — master ( 2452cb...36c8a5 )
by RN
01:50
created
src/Dolphin/Dolphin.php 1 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/QueryBuilder.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -79,37 +79,37 @@
 block discarded – undo
79 79
     }
80 80
 
81 81
     private function buildLimitQuery($limit, $offset, $query = []){
82
-      $limitQuery = [];
83
-      if (!empty($limit)) {
84
-          $query[] = 'LIMIT';
82
+        $limitQuery = [];
83
+        if (!empty($limit)) {
84
+            $query[] = 'LIMIT';
85 85
 
86
-          if (!empty($offset)) {
87
-              $query[] = $offset.',';
88
-          }
86
+            if (!empty($offset)) {
87
+                $query[] = $offset.',';
88
+            }
89 89
 
90
-          $query[] = $limit;
91
-      }
90
+            $query[] = $limit;
91
+        }
92 92
 
93
-      if (count($limitQuery)) {
94
-          $query = array_merge($query, $limitQuery);
95
-      }
96
-      return $query;
93
+        if (count($limitQuery)) {
94
+            $query = array_merge($query, $limitQuery);
95
+        }
96
+        return $query;
97 97
     }
98 98
 
99 99
     public function query($query, $fetchRows){
100
-      try {
101
-          $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ);
102
-
103
-          if ($fetchRows == 'count') {
104
-              $obj = $obj->fetchColumn();
105
-          }
106
-
107
-          return $obj;
108
-      } catch (\PDOException $ex) {
109
-          throw new \PDOException($ex->getMessage(), 1);
110
-      } catch (Exception $e) {
111
-          throw new Exception($e->getMessage(), 1);
112
-      }
100
+        try {
101
+            $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ);
102
+
103
+            if ($fetchRows == 'count') {
104
+                $obj = $obj->fetchColumn();
105
+            }
106
+
107
+            return $obj;
108
+        } catch (\PDOException $ex) {
109
+            throw new \PDOException($ex->getMessage(), 1);
110
+        } catch (Exception $e) {
111
+            throw new Exception($e->getMessage(), 1);
112
+        }
113 113
     }
114 114
 
115 115
     public function buildQuery(array $params)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         return "'".$field."'";
70 70
     }
71 71
 
72
-    private function getQueryFields($fields, $tbl){
72
+    private function getQueryFields($fields, $tbl) {
73 73
         $startQuery = join(', ', $fields);
74 74
         if (empty($fields)) {
75 75
             $startQuery = $this->quote($tbl).'.*';
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         return $startQuery;
79 79
     }
80 80
 
81
-    private function buildLimitQuery($limit, $offset, $query = []){
81
+    private function buildLimitQuery($limit, $offset, $query = []) {
82 82
       $limitQuery = [];
83 83
       if (!empty($limit)) {
84 84
           $query[] = 'LIMIT';
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
       return $query;
97 97
     }
98 98
 
99
-    public function query($query, $fetchRows){
99
+    public function query($query, $fetchRows) {
100 100
       try {
101 101
           $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ);
102 102
 
Please login to merge, or discard this patch.