Passed
Push — master ( 36c8a5...213898 )
by RN
01:43
created
src/Dolphin/Save.php 1 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 = []){
25
+    public function buildQueryStrSingleFromArr($row = []) {
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.
src/Dolphin/Dolphin.php 1 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.