Passed
Push — main ( 87ff2b...4745a3 )
by Sammy
02:38
created
src/CruditesExceptionFactory.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
         list($state, $code, $message) = $errorInfo;
56 56
         $functs = [
57 57
             // violation: column cannot be null
58
-            1048 => function ($message) {
58
+            1048 => function($message) {
59 59
                 preg_match("#Column '(.+)' cannot be null#", $message, $m);
60 60
                 return ['FIELD_REQUIRED', $m[1]];
61 61
             },
62 62
 
63
-            1054 => function ($message) {
63
+            1054 => function($message) {
64 64
                 return ['COLUMN_DOES_NOT_EXIST', $message];
65 65
             },
66 66
 
67 67
             // violation: duplicate key
68
-            1062 => function ($message) {
68
+            1062 => function($message) {
69 69
                 if (preg_match("#'([^']+)' for key '([^']+)'#", $message, $m)) {
70 70
                     $entry = $m[1];
71 71
                     $key = $m[2];
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
                 return ["DUPLICATE_KEY:".$m[1]];
80 80
             },
81 81
 
82
-            1064 => function ($message) {
82
+            1064 => function($message) {
83 83
                 preg_match("#right syntax to use near '(.+)'#", $message, $m);
84 84
                 return ['SYNTAX_ERROR', $m[1]];
85 85
             },
86 86
 
87
-            1146 => function ($message) {
87
+            1146 => function($message) {
88 88
                 return ['TABLE_DOES_NOT_EXIST', $message];
89 89
             },
90 90
 
91
-            1264 => function ($message) {
91
+            1264 => function($message) {
92 92
                 preg_match("#for column '(.+)'#", $message, $m);
93 93
                 return ['VALUE_OUT_OF_RANGE', $m[1]];
94 94
             },
95 95
 
96
-            1364 => function ($message) {
96
+            1364 => function($message) {
97 97
                 return ['FIELD_REQUIRED', $message];
98 98
             },
99 99
 
100
-            1451 => function ($message) {
100
+            1451 => function($message) {
101 101
                 preg_match("#CONSTRAINT `(.+)` FOREIGN#", $message, $m);
102 102
                 return ['RELATIONAL_INTEGRITY', $m[1]];
103 103
             },
@@ -106,6 +106,6 @@  discard block
 block discarded – undo
106 106
         if (isset($functs[$code]))
107 107
             return [call_user_func($functs[$code], $message), $code];
108 108
 
109
-        return ['FUBAR #' . $state . '-' . $code . '-' . $message, $code];
109
+        return ['FUBAR #'.$state.'-'.$code.'-'.$message, $code];
110 110
     }
111 111
 }
Please login to merge, or discard this patch.
src/Errors/CruditesError.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
         $this->message = $message;
17 17
     }
18 18
 
19
-    public function __toString(){
19
+    public function __toString() {
20 20
         $ret = $this->message;
21 21
         
22
-        if(!empty($this->table))
22
+        if (!empty($this->table))
23 23
             $ret .= sprintf(' on table "%s"', $this->table);
24
-        if(!empty($this->columns))
24
+        if (!empty($this->columns))
25 25
             $ret .= sprintf(' on column(s) "%s"', implode('", "', $this->columns));
26 26
 
27 27
         return $ret;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $errorInfo = null;
33 33
 
34
-        if(method_exists($something_PDO, 'errorInfo'))
34
+        if (method_exists($something_PDO, 'errorInfo'))
35 35
             $errorInfo = $something_PDO->errorInfo();
36
-        elseif(property_exists($something_PDO, 'errorInfo'))
36
+        elseif (property_exists($something_PDO, 'errorInfo'))
37 37
             $errorInfo = $something_PDO->errorInfo;
38 38
         else
39 39
             throw new \InvalidArgumentException('INVALID_PDO_CLASS');
Please login to merge, or discard this patch.
src/Crudites.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $select->selectAlso(['count' => ['COUNT(*)']]);
56 56
         $res = $select->retCol();
57 57
         if (is_array($res)) {
58
-            return (int) current($res);
58
+            return (int)current($res);
59 59
         }
60 60
 
61 61
         return null;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             $res->execute($dat_ass);
97 97
         }
98 98
         
99
-        return $res instanceof \PDOStatement? $res : null;
99
+        return $res instanceof \PDOStatement ? $res : null;
100 100
     }
101 101
 
102 102
     public static function distinctFor(string $table, string $column_name, string $filter_by_value = null)
Please login to merge, or discard this patch.
src/Grammar/ClauseWhere.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $this->where ??= [];
29 29
         $this->where[] = sprintf('(%s)', $where_condition);
30 30
 
31
-        if(!empty($bindings)){
31
+        if (!empty($bindings)) {
32 32
             $this->bindings = array_merge($this->bindings, $bindings);
33 33
         }
34 34
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         return $this->wherePredicate($p);
118 118
     }
119 119
 
120
-    private function predicateColumn($column, $table=null): array
120
+    private function predicateColumn($column, $table = null): array
121 121
     {
122 122
         return [$this->tableLabel($table), $column];
123 123
     }
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     protected function generateWhere()
222 222
     {
223 223
         if (!empty($this->where)) {
224
-            return PHP_EOL . ' WHERE ' . implode(PHP_EOL . ' AND ', $this->where);
224
+            return PHP_EOL.' WHERE '.implode(PHP_EOL.' AND ', $this->where);
225 225
         }
226 226
     }
227 227
 }
Please login to merge, or discard this patch.
src/Grammar/ClauseJoin.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function addJoinedTable($join_table_name, $join_table_alias)
26 26
     {
27
-        if(!isset($this->joined_tables[$join_table_alias])){
27
+        if (!isset($this->joined_tables[$join_table_alias])) {
28 28
             $this->joined_tables[$join_table_alias] = $join_table_name;
29 29
         }
30
-        elseif ($this->joined_tables[$join_table_alias] !== $join_table_name){
30
+        elseif ($this->joined_tables[$join_table_alias] !== $join_table_name) {
31 31
             throw new \InvalidArgumentException(sprintf(__FUNCTION__.'(): ALIAS `%s` ALREADY ALLOCATED FOR TABLE  `%s`', $join_table_alias, $join_table_name));
32 32
         }
33 33
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function join($table_names, $joins, $join_type = '')
37 37
     {
38
-        list($join_table_name,$join_table_alias) = self::processParamTableNames($table_names);
38
+        list($join_table_name, $join_table_alias) = self::processParamTableNames($table_names);
39 39
 
40 40
         if (preg_match('#^(INNER|LEFT|RIGHT|FULL)(\sOUTER)?#i', $join_type) !== 1) {
41 41
             $join_type = '';
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
             } 
75 75
             // 3 join params -> t.f = v
76
-            else{ 
76
+            else { 
77 77
                 $value = $join_field[0];
78 78
                 // join bind label
79 79
 
Please login to merge, or discard this patch.
src/Grammar/Query/Query.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         if (empty($this->bindings)) {
31 31
             unset($dbg['bindings']);
32 32
         }
33
-        else{
33
+        else {
34 34
             $dbg['bindings'] = json_encode($dbg['bindings']);
35 35
         }
36 36
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function bindLabel($field, $table_name = null): string
128 128
     {
129
-        return ':' . $this->tableLabel($table_name) . '_' . $field;
129
+        return ':'.$this->tableLabel($table_name).'_'.$field;
130 130
     }
131 131
 
132 132
     public function addBindings($assoc_data): array
Please login to merge, or discard this patch.
src/Grammar/Query/Insert.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         $fields = $this->getBindingNames();
27 27
         $fields = array_keys($fields[$this->table]);
28 28
         
29
-        $fields = '`' . implode('`, `', $fields) . '`';
29
+        $fields = '`'.implode('`, `', $fields).'`';
30 30
         $bindings = implode(', ', array_keys($this->bindings()));
31 31
 
32 32
         return sprintf('INSERT INTO `%s` (%s) VALUES (%s)', $this->table, $fields, $bindings);
Please login to merge, or discard this patch.
src/Grammar/Clause/Having.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function add($column, string $operator, $value): self
18 18
     {
19
-        $this->conditions .= ' AND ' . $this->process($column, $operator, $value);
19
+        $this->conditions .= ' AND '.$this->process($column, $operator, $value);
20 20
 
21 21
         return $this;
22 22
     }
23 23
 
24 24
     public function __toString()
25 25
     {
26
-        return empty($this->conditions) ? '' : 'HAVING ' . $this->conditions;
26
+        return empty($this->conditions) ? '' : 'HAVING '.$this->conditions;
27 27
     }
28 28
 
29 29
     public function name(): string
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     private function process($column, string $operator, $value): string
35 35
     {
36 36
         $predicate = new Predicate($column, $operator);
37
-        $predicate->withValue($value, __CLASS__ . '_' . count($this->bindings));
37
+        $predicate->withValue($value, __CLASS__.'_'.count($this->bindings));
38 38
 
39 39
         $this->bindings = array_merge($this->bindings, $predicate->bindings());
40 40
         return $predicate->__toString();
Please login to merge, or discard this patch.
src/Grammar/Clause/Join.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
     public function on($column, $join_table, $join_column): self
40 40
     {
41
-        $this->on = '' . (new Predicate([$this->alias, $column], '='))->withColumn([$join_table, $join_column]););
41
+        $this->on = ''.(new Predicate([$this->alias, $column], '='))->withColumn([$join_table, $join_column]););
42 42
         
43 43
 
44 44
         return $this;
Please login to merge, or discard this patch.