Passed
Push — master ( 36c8a5...213898 )
by RN
01:43
created
src/Dolphin/Builders/PrepareQueryBuilder.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 class PrepareQueryBuilder extends QueryBuilder
20 20
 {
21 21
     private function checkCountable($results = null ): bool{
22
-       return (is_array($results) || is_object($results)) && count($results);
22
+        return (is_array($results) || is_object($results)) && count($results);
23 23
     }
24 24
 
25 25
     /**
@@ -31,33 +31,33 @@  discard block
 block discarded – undo
31 31
      * @author RN Kushwaha <[email protected]>
32 32
      * @since v0.0.5
33 33
      */
34
-     public function prepare($where, $className, $query, $fetchRows = 'all')
35
-     {
36
-         $wqp  = new WhereQueryParser();
37
-         $util = new Utils();
38
-         $rows = null;
39
-
40
-         try {
41
-             $ar = $wqp->parseWhereQuery($where);
42
-             $stmt = Connection::get()->prepare($this->queryPrefix($query));
43
-             $stmt->execute($ar);
44
-
45
-             if ($fetchRows == 'first') {
46
-                 $results = $stmt->fetch(\PDO::FETCH_ASSOC);
47
-             } else{
48
-                 $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
49
-             }
50
-
51
-             if($this->checkCountable($results) ){
52
-               // now turn this stdClass object to the object type of calling model
53
-               $rows = $util->turnObjects($className, $results);
54
-             }
55
-
56
-             return $rows;
57
-         } catch (\PDOException $ex) {
58
-             throw new \PDOException($ex->getMessage(), 1);
59
-         } catch (Exception $e) {
60
-             throw new Exception($e->getMessage(), 1);
61
-         }
62
-     }
34
+        public function prepare($where, $className, $query, $fetchRows = 'all')
35
+        {
36
+            $wqp  = new WhereQueryParser();
37
+            $util = new Utils();
38
+            $rows = null;
39
+
40
+            try {
41
+                $ar = $wqp->parseWhereQuery($where);
42
+                $stmt = Connection::get()->prepare($this->queryPrefix($query));
43
+                $stmt->execute($ar);
44
+
45
+                if ($fetchRows == 'first') {
46
+                    $results = $stmt->fetch(\PDO::FETCH_ASSOC);
47
+                } else{
48
+                    $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
49
+                }
50
+
51
+                if($this->checkCountable($results) ){
52
+                // now turn this stdClass object to the object type of calling model
53
+                $rows = $util->turnObjects($className, $results);
54
+                }
55
+
56
+                return $rows;
57
+            } catch (\PDOException $ex) {
58
+                throw new \PDOException($ex->getMessage(), 1);
59
+            } catch (Exception $e) {
60
+                throw new Exception($e->getMessage(), 1);
61
+            }
62
+        }
63 63
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class PrepareQueryBuilder extends QueryBuilder
20 20
 {
21
-    private function checkCountable($results = null ): bool{
21
+    private function checkCountable($results = null): bool{
22 22
        return (is_array($results) || is_object($results)) && count($results);
23 23
     }
24 24
 
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
              if ($fetchRows == 'first') {
46 46
                  $results = $stmt->fetch(\PDO::FETCH_ASSOC);
47
-             } else{
47
+             } else {
48 48
                  $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
49 49
              }
50 50
 
51
-             if($this->checkCountable($results) ){
51
+             if ($this->checkCountable($results)) {
52 52
                // now turn this stdClass object to the object type of calling model
53 53
                $rows = $util->turnObjects($className, $results);
54 54
              }
Please login to merge, or discard this patch.
src/Dolphin/Dolphin.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
     public function update($row)
375 375
     {
376 376
         $result =  (new UpdateQueryBuilder())->update(
377
-          $row,
378
-          $this->table,
379
-          $this->where,
380
-          $this->whereRaw,
381
-          $this->whereIn,
382
-          $this->whereNotIn,
383
-          $this->whereNull,
384
-          $this->whereNotNull
377
+            $row,
378
+            $this->table,
379
+            $this->where,
380
+            $this->whereRaw,
381
+            $this->whereIn,
382
+            $this->whereNotIn,
383
+            $this->whereNull,
384
+            $this->whereNotNull
385 385
         );
386 386
 
387 387
         $this->reset();
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
     public function delete()
421 421
     {
422 422
         $result =  (new DeleteQueryBuilder())->delete(
423
-          $this->table,
424
-          $this->where,
425
-          $this->whereRaw,
426
-          $this->whereIn,
427
-          $this->whereNotIn,
428
-          $this->whereNull,
429
-          $this->whereNotNull
423
+            $this->table,
424
+            $this->where,
425
+            $this->whereRaw,
426
+            $this->whereIn,
427
+            $this->whereNotIn,
428
+            $this->whereNull,
429
+            $this->whereNotNull
430 430
         );
431 431
 
432 432
         $this->reset();
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
     protected $offset;
74 74
     protected $results;
75 75
 
76
-    private function getFields(array $args, bool $quote = true){
76
+    private function getFields(array $args, bool $quote = true) {
77 77
         return (new QueryBuilder())->getFields($args, $quote);
78 78
     }
79 79
 
80
-    private function validateArgsCount($noOfArgs){
81
-        if($noOfArgs<2 || $noOfArgs >3){
80
+    private function validateArgsCount($noOfArgs) {
81
+        if ($noOfArgs < 2 || $noOfArgs > 3) {
82 82
             throw new Exception('Where parameter contains invalid number of parameters', 1);
83 83
         }
84 84
     }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $noOfArgs = func_num_args();
139 139
         $this->validateArgsCount($noOfArgs);
140 140
 
141
-        if($noOfArgs===2){
141
+        if ($noOfArgs === 2) {
142 142
             $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]);
143 143
             return $this;
144 144
         }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     protected function buildQuery()
225 225
     {
226
-        $query  = (new QueryBuilder())->buildQuery([
226
+        $query = (new QueryBuilder())->buildQuery([
227 227
             'table' => $this->table,
228 228
             'fields' => $this->fields,
229 229
             'join' => $this->join,
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         $this->where('id', $id);
335 335
         $row = $this->first();
336 336
 
337
-        if($row == null ){
337
+        if ($row == null) {
338 338
             throw new Exception("The record does not exists!");
339 339
         }
340 340
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function update($row)
375 375
     {
376
-        $result =  (new UpdateQueryBuilder())->update(
376
+        $result = (new UpdateQueryBuilder())->update(
377 377
           $row,
378 378
           $this->table,
379 379
           $this->where,
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
         $qb = new QueryBuilder();
402 402
         $query = "TRUNCATE ".$this->table;
403 403
 
404
-        try{
404
+        try {
405 405
             Connection::get()->query($qb->queryPrefix($query));
406
-        } catch(Exception $e){
406
+        } catch (Exception $e) {
407 407
             throw new Exception($e->getMessage());
408 408
         }
409 409
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function delete()
421 421
     {
422
-        $result =  (new DeleteQueryBuilder())->delete(
422
+        $result = (new DeleteQueryBuilder())->delete(
423 423
           $this->table,
424 424
           $this->where,
425 425
           $this->whereRaw,
Please login to merge, or discard this patch.