Passed
Branch main (b4b05f)
by Sammy
03:19
created
src/Row.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function __toString()
47 47
     {
48
-        return PHP_EOL . 'load: '
48
+        return PHP_EOL.'load: '
49 49
             . json_encode($this->load)
50
-            . PHP_EOL . 'alterations: '
50
+            . PHP_EOL.'alterations: '
51 51
             . json_encode(array_keys($this->alterations));
52 52
     }
53 53
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     {
135 135
         foreach (array_keys($datass) as $field_name) {
136 136
 
137
-            if($datass[$field_name] === $this->get($field_name)) {
137
+            if ($datass[$field_name] === $this->get($field_name)) {
138 138
                 continue;
139 139
             }
140 140
             
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             }
151 151
 
152 152
             // Replace empty strings with null if the column is nullable
153
-            if (trim('' . $datass[$field_name]) === '' && $attributes->nullable()) {
153
+            if (trim(''.$datass[$field_name]) === '' && $attributes->nullable()) {
154 154
                 $datass[$field_name] = null;
155 155
             }
156 156
 
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
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $res = self::$connection->result($select);
62 62
         $res = $res->ret(\PDO::FETCH_COLUMN);
63 63
         if (is_array($res)) {
64
-            return (int) current($res);
64
+            return (int)current($res);
65 65
         }
66 66
 
67 67
         return null;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $ret = [];
79 79
 
80 80
         $res = self::$connection->result($select);
81
-        if($res->ran()) {
81
+        if ($res->ran()) {
82 82
 
83 83
             $primary_keys = self::$connection->schema()->primaryKeys($select->table());
84 84
             $pk_name = implode('_', $primary_keys);
Please login to merge, or discard this patch.
src/Grammar/Query/Query.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         if (empty($this->bindings)) {
38 38
             unset($dbg['bindings']);
39 39
         }
40
-        else{
40
+        else {
41 41
             $dbg['bindings'] = json_encode($dbg['bindings']);
42 42
         }
43 43
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 
99 99
     public function bindings(): array
100 100
     {
101
-        if(empty($this->clauses)){
101
+        if (empty($this->clauses)) {
102 102
             return $this->bindings;
103 103
         }
104 104
 
105
-        return array_merge($this->bindings, array_reduce($this->clauses, function ($carry, $clause) {
105
+        return array_merge($this->bindings, array_reduce($this->clauses, function($carry, $clause) {
106 106
             return array_merge($carry, $clause->bindings());
107 107
         }, []));
108 108
     }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     public function bindLabel($field, $table_name = null): string
120 120
     {
121
-        return ':' . $this->tableLabel($table_name) . '_' . $field;
121
+        return ':'.$this->tableLabel($table_name).'_'.$field;
122 122
     }
123 123
 
124 124
     public function addBindings($assoc_data, $binding_label = null): array
Please login to merge, or discard this patch.
src/Grammar/Query/Insert.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function values(array $dat_ass): self
23 23
     {
24
-        $this->binding_names []= $this->addBindings($dat_ass);
24
+        $this->binding_names [] = $this->addBindings($dat_ass);
25 25
 
26 26
         return $this;
27 27
     }
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 
38 38
         $fields_labels = array_shift($this->binding_names);
39 39
         $fields = array_keys($fields_labels);
40
-        $fields = '`' . implode('`,`', $fields) . '`';
40
+        $fields = '`'.implode('`,`', $fields).'`';
41 41
 
42 42
         $bindings = implode(',:', $fields_labels);
43 43
 
44 44
         $statement = sprintf('INSERT INTO `%s` (%s) VALUES (:%s)', $this->table, $fields, $bindings);
45
-        foreach($this->binding_names as $bindings){
45
+        foreach ($this->binding_names as $bindings) {
46 46
             $statement .= sprintf(',(:%s)', implode(',:', $bindings));
47 47
         }
48 48
 
Please login to merge, or discard this patch.
src/Grammar/Query/Select.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $schema = Grammar::identifier($this->table());
32 32
         if (!empty($this->alias())) {
33
-            $schema .= ' ' . Grammar::identifier($this->alias());
33
+            $schema .= ' '.Grammar::identifier($this->alias());
34 34
         }
35 35
 
36 36
         $ret = sprintf('SELECT %s FROM %s', $this->deck, $schema);
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
                 Clause::LIMIT
47 47
             ] as $clause
48 48
         ) {
49
-            if($this->clause($clause) === null)
49
+            if ($this->clause($clause) === null)
50 50
                 continue;
51 51
 
52
-            $ret .= ' ' . $this->clause($clause);
52
+            $ret .= ' '.$this->clause($clause);
53 53
         }
54 54
 
55 55
         return $ret;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             if (is_int($alias)) {
87 87
                 $alias = null;
88 88
             }
89
-            if(!isset($this->deck)){
89
+            if (!isset($this->deck)) {
90 90
                 $this->deck = new Deck($column, $alias);
91 91
             } else {
92 92
                 $this->deck->add($column, $alias);
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
         return $where;
104 104
     }
105 105
 
106
-    public function join(string $table, ?string $alias=null): Join
106
+    public function join(string $table, ?string $alias = null): Join
107 107
     {
108 108
         $join = new Join($table, $alias);
109 109
 
110
-        if($this->clause(Clause::JOINS) === null){
110
+        if ($this->clause(Clause::JOINS) === null) {
111 111
             $joins = new Joins([$join]);
112 112
             $this->add($joins);
113 113
         }
114
-        else{
114
+        else {
115 115
             $this->clause(Clause::JOINS)->add($join);
116 116
         }
117 117
 
Please login to merge, or discard this 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/Grammar/Clause/Join.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     public function __toString(): string
54 54
     {
55
-        if(isset($this->column, $this->referenced_table, $this->referenced_column)) {
55
+        if (isset($this->column, $this->referenced_table, $this->referenced_column)) {
56 56
             $on = (string)(new Predicate([$this->alias, $this->column], '=', [$this->referenced_table, $this->referenced_column]));
57 57
         }
58 58
         
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function referenced(): ?array
94 94
     {
95
-        if(isset($this->referenced_table, $this->referenced_column)) {
95
+        if (isset($this->referenced_table, $this->referenced_column)) {
96 96
             return [$this->referenced_table, $this->referenced_column];
97 97
         }
98 98
 
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.
tests/Query/SelectTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,13 +100,13 @@
 block discarded – undo
100 100
         $this->assertEquals($expected, (string)$query);
101 101
 
102 102
         $query->join('products', 'p')->on('product_id', 'oi', 'product_id');
103
-        $this->assertEquals($expected .' JOIN `products` `p` ON `p`.`product_id` = `oi`.`product_id`', (string)$query);
103
+        $this->assertEquals($expected.' JOIN `products` `p` ON `p`.`product_id` = `oi`.`product_id`', (string)$query);
104 104
         
105 105
         $query->selectAlso(['productName' => ['p', 'name']]);
106 106
         $expected = 'SELECT quantity,price AS `sold_price`,`p`.`name` AS `productName` FROM `order_items` `oi` JOIN `products` `p` ON `p`.`product_id` = `oi`.`product_id`';
107 107
         $this->assertEquals($expected, (string)$query);
108 108
 
109
-        $query->join('orders', 'o')->on('order_id','oi', 'order_id');
109
+        $query->join('orders', 'o')->on('order_id', 'oi', 'order_id');
110 110
         $expected .= ' JOIN `orders` `o` ON `o`.`order_id` = `oi`.`order_id`';
111 111
         $this->assertEquals($expected, (string)$query);
112 112
 
Please login to merge, or discard this patch.