Passed
Branch main (b4b05f)
by Sammy
03:19
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/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/Grammar/Query/Select.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
                 Clause::LIMIT
47 47
             ] as $clause
48 48
         ) {
49
-            if($this->clause($clause) === null)
50
-                continue;
49
+            if($this->clause($clause) === null) {
50
+                            continue;
51
+            }
51 52
 
52 53
             $ret .= ' ' . $this->clause($clause);
53 54
         }
@@ -78,8 +79,9 @@  discard block
 block discarded – undo
78 79
      */
79 80
     public function selectAlso(array $setter): self
80 81
     {
81
-        if (empty($setter))
82
-            throw new \InvalidArgumentException('EMPTY_SETTER_ARRAY');
82
+        if (empty($setter)) {
83
+                    throw new \InvalidArgumentException('EMPTY_SETTER_ARRAY');
84
+        }
83 85
 
84 86
         foreach ($setter as $alias => $column) {
85 87
 
@@ -110,8 +112,7 @@  discard block
 block discarded – undo
110 112
         if($this->clause(Clause::JOINS) === null){
111 113
             $joins = new Joins([$join]);
112 114
             $this->add($joins);
113
-        }
114
-        else{
115
+        } else{
115 116
             $this->clause(Clause::JOINS)->add($join);
116 117
         }
117 118
 
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
@@ -14,10 +14,11 @@
 block discarded – undo
14 14
 
15 15
         if ($predicates !== null) {
16 16
             foreach ($predicates as $predicate) {
17
-                if (is_string($predicate))
18
-                    $this->and($predicate);
19
-                else
20
-                    $this->and($predicate, $predicate->bindings());
17
+                if (is_string($predicate)) {
18
+                                    $this->and($predicate);
19
+                } else {
20
+                                    $this->and($predicate, $predicate->bindings());
21
+                }
21 22
             }
22 23
         }
23 24
     }
Please login to merge, or discard this patch.
src/Result.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
             $this->statement = $statement;
73 73
         }
74 74
 
75
-        if ($this->statement instanceof \PDOStatement)
76
-            $this->prepared = $this->statement;
75
+        if ($this->statement instanceof \PDOStatement) {
76
+                    $this->prepared = $this->statement;
77
+        }
77 78
 
78 79
         $this->run($bindings);
79 80
     }
@@ -97,8 +98,9 @@  discard block
 block discarded – undo
97 98
             $pdo_cascade = $this->pdo;
98 99
         }
99 100
         // two time testing is necessary, f.i. lastInsertId is a PDO method, not a PDOStatement method
100
-        if ($pdo_cascade === null || !method_exists($pdo_cascade, $method))
101
-            throw new \BadMethodCallException("__call($method) not possible in PDO or PDOStatement");
101
+        if ($pdo_cascade === null || !method_exists($pdo_cascade, $method)) {
102
+                    throw new \BadMethodCallException("__call($method) not possible in PDO or PDOStatement");
103
+        }
102 104
 
103 105
         return call_user_func_array([$pdo_cascade, $method], $args);
104 106
     }
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
             throw new CruditesException('No executed statement available for fetching results');
131 133
         }
132 134
 
133
-        if ($mode === \PDO::FETCH_CLASS)
134
-            return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args);
135
+        if ($mode === \PDO::FETCH_CLASS) {
136
+                    return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args);
137
+        }
135 138
 
136 139
         return $this->executed->fetchAll($mode);
137 140
     }
Please login to merge, or discard this patch.