Passed
Branch main (b4b05f)
by Sammy
03:19
created
src/Grammar/Predicate.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function withValue($value, string $bind_label = null): self
64 64
     {
65 65
         $this->bindings[$this->bindLabel($bind_label)] = $value;
66
-        $this->right = ':' . $this->bindLabel($bind_label);
66
+        $this->right = ':'.$this->bindLabel($bind_label);
67 67
         return $this;
68 68
     }
69 69
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         }
80 80
 
81 81
         $this->operator = 'IN';
82
-        $this->right = '(:' . implode(',:', array_keys($this->bindings)) . ')';
82
+        $this->right = '(:'.implode(',:', array_keys($this->bindings)).')';
83 83
 
84 84
         return $this;
85 85
     }
Please login to merge, or discard this 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 2 patches
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.
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/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/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/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.
tests/RowTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     private string $table = 'users';
13 13
     private array $data_pk_match = ['id' => 1];
14 14
     private array $data_form = ['name' => 'Test', 'username' => 'john_doe'];
15
-    private array $data_form_with_id = ['name' => 'Test', 'username' => 'john_doe'] + ['id' => 1];
15
+    private array $data_form_with_id = ['name' => 'Test', 'username' => 'john_doe']+['id' => 1];
16 16
     
17 17
     // setup
18 18
     public function setUp(): void
Please login to merge, or discard this patch.