Passed
Push — main ( 39b0f6...4f7abe )
by Sammy
22:35
created
src/Errors/CruditesError.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,10 +19,12 @@  discard block
 block discarded – undo
19 19
     public function __toString(){
20 20
         $ret = $this->message;
21 21
         
22
-        if(!empty($this->table))
23
-            $ret .= sprintf(' on table "%s"', $this->table);
24
-        if(!empty($this->columns))
25
-            $ret .= sprintf(' on column(s) "%s"', implode('", "', $this->columns));
22
+        if(!empty($this->table)) {
23
+                    $ret .= sprintf(' on table "%s"', $this->table);
24
+        }
25
+        if(!empty($this->columns)) {
26
+                    $ret .= sprintf(' on column(s) "%s"', implode('", "', $this->columns));
27
+        }
26 28
 
27 29
         return $ret;
28 30
     }
@@ -31,12 +33,13 @@  discard block
 block discarded – undo
31 33
     {
32 34
         $errorInfo = null;
33 35
 
34
-        if(method_exists($something_PDO, 'errorInfo'))
35
-            $errorInfo = $something_PDO->errorInfo();
36
-        elseif(property_exists($something_PDO, 'errorInfo'))
37
-            $errorInfo = $something_PDO->errorInfo;
38
-        else
39
-            throw new \InvalidArgumentException('INVALID_PDO_CLASS');
36
+        if(method_exists($something_PDO, 'errorInfo')) {
37
+                    $errorInfo = $something_PDO->errorInfo();
38
+        } elseif(property_exists($something_PDO, 'errorInfo')) {
39
+                    $errorInfo = $something_PDO->errorInfo;
40
+        } else {
41
+                    throw new \InvalidArgumentException('INVALID_PDO_CLASS');
42
+        }
40 43
 
41 44
         // 0: the SQLSTATE associated with the last operation on the database handle
42 45
         $this->setState($errorInfo[0] ?? null);
Please login to merge, or discard this patch.
src/CruditesExceptionFactory.php 1 patch
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,19 +20,22 @@  discard block
 block discarded – undo
20 20
     {
21 21
         $errorInfo = null;
22 22
 
23
-        if (!$query->isSuccess())
24
-            $errorInfo = $query->errorInfo();
25
-        elseif ($exception !== null)
26
-            $errorInfo = $exception->errorInfo;
23
+        if (!$query->isSuccess()) {
24
+                    $errorInfo = $query->errorInfo();
25
+        } elseif ($exception !== null) {
26
+                    $errorInfo = $exception->errorInfo;
27
+        }
27 28
 
28
-        if (!is_array($errorInfo))
29
-            return new CruditesException('ERROR_INFO_UNAVAILABLE', 0, $exception);
29
+        if (!is_array($errorInfo)) {
30
+                    return new CruditesException('ERROR_INFO_UNAVAILABLE', 0, $exception);
31
+        }
30 32
 
31 33
         list($message, $code) = self::transcript($errorInfo);
32 34
 
33 35
         // TODO: losing the parsing work from transcript. IMPROVE
34
-        if (is_array($message))
35
-            $message = array_shift($message);
36
+        if (is_array($message)) {
37
+                    $message = array_shift($message);
38
+        }
36 39
 
37 40
         return new CruditesException($message, $code, null); // exception could reveal database credentials
38 41
     }
@@ -103,8 +106,9 @@  discard block
 block discarded – undo
103 106
             },
104 107
 
105 108
         ];
106
-        if (isset($functs[$code]))
107
-            return [call_user_func($functs[$code], $message), $code];
109
+        if (isset($functs[$code])) {
110
+                    return [call_user_func($functs[$code], $message), $code];
111
+        }
108 112
 
109 113
         return ['FUBAR #' . $state . '-' . $code . '-' . $message, $code];
110 114
     }
Please login to merge, or discard this patch.
src/Grammar/Query/Query.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@
 block discarded – undo
33 33
         
34 34
         if (empty($this->bindings)) {
35 35
             unset($dbg['bindings']);
36
-        }
37
-        else{
36
+        } else{
38 37
             $dbg['bindings'] = json_encode($dbg['bindings']);
39 38
         }
40 39
 
Please login to merge, or discard this patch.
src/Relation/DatabaseRelations.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,22 +32,19 @@
 block discarded – undo
32 32
             if(count($join) == 1){
33 33
                 $res = new HasOne($table, $join,$this->connection);
34 34
                 $relations["$res"] = $res;
35
-            }
36
-            else if(count($join) == 2){
35
+            } else if(count($join) == 2){
37 36
                 $res = new OneToMany($table, $join,$this->connection);
38 37
                 $relations["$res"] = $res;
39 38
 
40 39
                 $res = new OneToMany($table, array_reverse($join),$this->connection);
41 40
                 $relations["$res"] = $res;
42
-            }
43
-            else if(count($join) == 3){
41
+            } else if(count($join) == 3){
44 42
                 $res = new OneToManyQualified($table, $join,$this->connection);
45 43
                 $relations["$res"] = $res;
46 44
 
47 45
                 $res = new OneToManyQualified($table, array_reverse($join),$this->connection);
48 46
                 $relations["$res"] = $res;
49
-            }
50
-            else
47
+            } else
51 48
             {
52 49
                 vd($join, 'skipping '.$table);
53 50
             }
Please login to merge, or discard this patch.
src/Grammar/Query/Select.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
                 Clause::LIMIT
40 40
             ] as $clause
41 41
         ) {
42
-            if($this->clause($clause) === null)
43
-                continue;
42
+            if($this->clause($clause) === null) {
43
+                            continue;
44
+            }
44 45
 
45 46
             $ret .= ' ' . $this->clause($clause);
46 47
         }
@@ -71,8 +72,9 @@  discard block
 block discarded – undo
71 72
      */
72 73
     public function selectAlso(array $setter): self
73 74
     {
74
-        if (empty($setter))
75
-            throw new \InvalidArgumentException('EMPTY_SETTER_ARRAY');
75
+        if (empty($setter)) {
76
+                    throw new \InvalidArgumentException('EMPTY_SETTER_ARRAY');
77
+        }
76 78
 
77 79
         foreach ($setter as $alias => $column) {
78 80
 
Please login to merge, or discard this patch.
src/Grammar/Clause/Where.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,10 +12,11 @@
 block discarded – undo
12 12
     {
13 13
         if ($predicates !== null) {
14 14
             foreach ($predicates as $predicate) {
15
-                if (is_string($predicate))
16
-                    $this->and($predicate);
17
-                else
18
-                    $this->and($predicate, $predicate->bindings());
15
+                if (is_string($predicate)) {
16
+                                    $this->and($predicate);
17
+                } else {
18
+                                    $this->and($predicate, $predicate->bindings());
19
+                }
19 20
             }
20 21
         }
21 22
     }
Please login to merge, or discard this patch.
src/Grammar/Predicate.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,8 +118,9 @@
 block discarded – undo
118 118
             return $this->bind_label;
119 119
         }
120 120
         // getter
121
-        else if ($this->bind_label !== null)
122
-            return $this->bind_label;
121
+        else if ($this->bind_label !== null) {
122
+                    return $this->bind_label;
123
+        }
123 124
 
124 125
         // generator
125 126
         else if (is_array($this->left)) {
Please login to merge, or discard this patch.
src/Crudites.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@
 block discarded – undo
42 42
         // no props, assumes connection made, verify and return
43 43
         if (isset($dsn, $user, $pass)) {
44 44
             self::$connection = new Connection($dsn, $user, $pass);
45
-        }
46
-        elseif (self::$connection === null) {
45
+        } elseif (self::$connection === null) {
47 46
             throw new CruditesException('NO_DATABASE');
48 47
         }
49 48
 
Please login to merge, or discard this patch.
src/Result.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,8 +70,9 @@  discard block
 block discarded – undo
70 70
             $this->statement = $statement;
71 71
         }
72 72
 
73
-        if ($this->statement instanceof \PDOStatement)
74
-            $this->prepared = $this->statement;
73
+        if ($this->statement instanceof \PDOStatement) {
74
+                    $this->prepared = $this->statement;
75
+        }
75 76
 
76 77
         $this->run($bindings);
77 78
     }
@@ -87,11 +88,13 @@  discard block
 block discarded – undo
87 88
         // make senses for chronology and error handling
88 89
         $pdo_statement = $this->executed ?? $this->prepared;
89 90
 
90
-        if ($pdo_statement === null)
91
-            throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method ' . $method);
91
+        if ($pdo_statement === null) {
92
+                    throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method ' . $method);
93
+        }
92 94
 
93
-        if (!method_exists($pdo_statement, $method))
94
-            throw new \BadMethodCallException("method $method not found in PDOStatement instance");
95
+        if (!method_exists($pdo_statement, $method)) {
96
+                    throw new \BadMethodCallException("method $method not found in PDOStatement instance");
97
+        }
95 98
 
96 99
         return call_user_func_array([$pdo_statement, $method], $args);
97 100
     }
@@ -164,8 +167,9 @@  discard block
 block discarded – undo
164 167
      */
165 168
     public function ret($mode = \PDO::FETCH_ASSOC, $fetch_argument = null, $ctor_args = null)
166 169
     {
167
-        if ($mode === \PDO::FETCH_CLASS)
168
-            return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args);
170
+        if ($mode === \PDO::FETCH_CLASS) {
171
+                    return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args);
172
+        }
169 173
 
170 174
         return $this->executed->fetchAll($mode);
171 175
     }
Please login to merge, or discard this patch.