Passed
Push — main ( 72ed59...7b3af7 )
by Sammy
01:55
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/ClauseJoin.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
     {
27 27
         if(!isset($this->joined_tables[$join_table_alias])){
28 28
             $this->joined_tables[$join_table_alias] = $join_table_name;
29
-        }
30
-        elseif ($this->joined_tables[$join_table_alias] !== $join_table_name){
29
+        } elseif ($this->joined_tables[$join_table_alias] !== $join_table_name){
31 30
             throw new \InvalidArgumentException(sprintf(__FUNCTION__.'(): ALIAS `%s` ALREADY ALLOCATED FOR TABLE  `%s`', $join_table_alias, $join_table_name));
32 31
         }
33 32
     }
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/Result.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
         $this->statement = $statement;
32 32
         $this->bindings = $bindings;
33 33
 
34
-        if ($statement instanceof \PDOStatement)
35
-            $this->prepared = $statement;
34
+        if ($statement instanceof \PDOStatement) {
35
+                    $this->prepared = $statement;
36
+        }
36 37
 
37 38
         $this->run($bindings);
38 39
     }
@@ -46,11 +47,13 @@  discard block
 block discarded – undo
46 47
     {
47 48
         $pdo_statement = $this->executed ?? $this->prepared;
48 49
 
49
-        if ($pdo_statement === null)
50
-            throw new CruditesException('RUN_OR_PREPARE_QUERY_BEFORE_CALLING_METHOD');
50
+        if ($pdo_statement === null) {
51
+                    throw new CruditesException('RUN_OR_PREPARE_QUERY_BEFORE_CALLING_METHOD');
52
+        }
51 53
 
52
-        if (!method_exists($pdo_statement, $method))
53
-            throw new \BadMethodCallException(__FUNCTION__ . " method $method() does not exist in PDOStatement class");
54
+        if (!method_exists($pdo_statement, $method)) {
55
+                    throw new \BadMethodCallException(__FUNCTION__ . " method $method() does not exist in PDOStatement class");
56
+        }
54 57
 
55 58
 
56 59
         return call_user_func_array([$pdo_statement, $method], $args);
@@ -173,11 +176,13 @@  discard block
 block discarded – undo
173 176
      */
174 177
     public function errorInfo(): array
175 178
     {
176
-        if ($this->executed !== null)
177
-            return $this->executed->errorInfo();
179
+        if ($this->executed !== null) {
180
+                    return $this->executed->errorInfo();
181
+        }
178 182
 
179
-        if ($this->prepared !== null)
180
-            return $this->prepared->errorInfo();
183
+        if ($this->prepared !== null) {
184
+                    return $this->prepared->errorInfo();
185
+        }
181 186
 
182 187
         return $this->pdo->errorInfo();
183 188
     }
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/Predicate.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,8 +112,9 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function bindLabel(string $prefix = null): string
114 114
     {
115
-        if ($this->bind_label !== null)
116
-            return $this->bind_label;
115
+        if ($this->bind_label !== null) {
116
+                    return $this->bind_label;
117
+        }
117 118
 
118 119
         if (is_string($this->right)) {
119 120
             $this->bind_label = $this->right;
@@ -123,8 +124,9 @@  discard block
 block discarded – undo
123 124
             $this->bind_label = $this->left;
124 125
         }
125 126
 
126
-        if ($prefix !== null)
127
-            $this->bind_label = $prefix . '_' . $this->bind_label;
127
+        if ($prefix !== null) {
128
+                    $this->bind_label = $prefix . '_' . $this->bind_label;
129
+        }
128 130
 
129 131
         return $this->bind_label;
130 132
     }
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/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.