Passed
Push — master ( e21e2a...b8c9e8 )
by y
01:28
created
src/DB/Select.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * @param string|Select $table
77 77
      * @param string[] $columns
78 78
      */
79
-    public function __construct (DB $db, $table, array $columns) {
79
+    public function __construct(DB $db, $table, array $columns) {
80 80
         parent::__construct($db);
81 81
         if ($table instanceof Select) {
82 82
             $table = $table->toSubquery();
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * Gives the clone a new alias.
101 101
      */
102
-    public function __clone () {
102
+    public function __clone() {
103 103
         $this->alias = uniqid('_') . "__{$this->table}";
104 104
     }
105 105
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * @param array $args
108 108
      * @return Statement
109 109
      */
110
-    public function __invoke (array $args = []): Statement {
110
+    public function __invoke(array $args = []): Statement {
111 111
         return $this->execute($args);
112 112
     }
113 113
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return string
118 118
      */
119
-    final public function __toString () {
119
+    final public function __toString() {
120 120
         return $this->alias;
121 121
     }
122 122
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param array $args Execution arguments.
127 127
      * @return int
128 128
      */
129
-    public function count (array $args = []): int {
129
+    public function count(array $args = []): int {
130 130
         $clone = clone $this;
131 131
         $clone->columns = ['COUNT(*)'];
132 132
         return (int)$clone->execute($args)->fetchColumn();
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @param array $args
139 139
      * @return Statement
140 140
      */
141
-    public function execute (array $args = []): Statement {
141
+    public function execute(array $args = []): Statement {
142 142
         if (!empty($args)) {
143 143
             return $this->prepare()($args);
144 144
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * @param array $args Execution arguments.
154 154
      * @return array
155 155
      */
156
-    public function fetchAll (array $args = []): array {
156
+    public function fetchAll(array $args = []): array {
157 157
         return $this->fetcher->__invoke($this->execute($args));
158 158
     }
159 159
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      *
165 165
      * @return ArrayIterator
166 166
      */
167
-    public function getIterator () {
167
+    public function getIterator() {
168 168
         return new ArrayIterator($this->fetchAll());
169 169
     }
170 170
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param string $column
175 175
      * @return $this
176 176
      */
177
-    public function group (string $column) {
177
+    public function group(string $column) {
178 178
         if (!strlen($this->_group)) {
179 179
             $this->_group = " GROUP BY {$column}";
180 180
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param string $condition
191 191
      * @return $this
192 192
      */
193
-    public function having (string $condition) {
193
+    public function having(string $condition) {
194 194
         $this->_having[] = $condition;
195 195
         return $this;
196 196
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @param string $type
204 204
      * @return $this
205 205
      */
206
-    public function join ($table, string $condition, string $type = 'INNER') {
206
+    public function join($table, string $condition, string $type = 'INNER') {
207 207
         if ($table instanceof Select) {
208 208
             $table = $table->toSubquery();
209 209
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param int $offset
219 219
      * @return $this
220 220
      */
221
-    public function limit (int $limit, int $offset = 0) {
221
+    public function limit(int $limit, int $offset = 0) {
222 222
         if ($limit == 0) {
223 223
             $this->_limit = '';
224 224
         }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      * @param string $name Name or alias if used.
238 238
      * @return bool
239 239
      */
240
-    public function offsetExists ($name): bool {
240
+    public function offsetExists($name): bool {
241 241
         return true;
242 242
     }
243 243
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * @param string $name Name, or alias if used.
248 248
      * @return Column
249 249
      */
250
-    public function offsetGet ($name): Column {
250
+    public function offsetGet($name): Column {
251 251
         return new Column($this->db, $name, $this->alias);
252 252
     }
253 253
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      * @param string $order
258 258
      * @return $this
259 259
      */
260
-    public function order (string $order) {
260
+    public function order(string $order) {
261 261
         if (strlen($order)) {
262 262
             $order = " ORDER BY {$order}";
263 263
         }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     /**
269 269
      * @return Statement
270 270
      */
271
-    public function prepare (): Statement {
271
+    public function prepare(): Statement {
272 272
         return $this->db->prepare($this->toSql());
273 273
     }
274 274
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      * @param Closure $fetcher
277 277
      * @return $this
278 278
      */
279
-    public function setFetcher (Closure $fetcher) {
279
+    public function setFetcher(Closure $fetcher) {
280 280
         $this->fetcher = $fetcher;
281 281
         return $this;
282 282
     }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     /**
285 285
      * @return string
286 286
      */
287
-    public function toSql (): string {
287
+    public function toSql(): string {
288 288
         $sql = 'SELECT ' . implode(', ', $this->columns) . ' FROM ' . $this->table;
289 289
         $sql .= $this->_join;
290 290
         if (!empty($this->_where)) {
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      *
305 305
      * @return string
306 306
      */
307
-    public function toSubquery (): string {
307
+    public function toSubquery(): string {
308 308
         return "({$this->toSql()}) AS {$this->alias}";
309 309
     }
310 310
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * @param string $condition
315 315
      * @return $this
316 316
      */
317
-    public function where (string $condition) {
317
+    public function where(string $condition) {
318 318
         $this->_where[] = $condition;
319 319
         return $this;
320 320
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,8 +86,7 @@  discard block
 block discarded – undo
86 86
         foreach ($columns as $alias => $name) {
87 87
             if (is_string($alias) and $name !== $alias) {
88 88
                 $this->columns[] = "{$name} AS {$alias}";
89
-            }
90
-            else {
89
+            } else {
91 90
                 $this->columns[] = $name;
92 91
             }
93 92
         }
@@ -177,8 +176,7 @@  discard block
 block discarded – undo
177 176
     public function group (string $column) {
178 177
         if (!strlen($this->_group)) {
179 178
             $this->_group = " GROUP BY {$column}";
180
-        }
181
-        else {
179
+        } else {
182 180
             $this->_group .= ", {$column}";
183 181
         }
184 182
         return $this;
@@ -221,8 +219,7 @@  discard block
 block discarded – undo
221 219
     public function limit (int $limit, int $offset = 0) {
222 220
         if ($limit == 0) {
223 221
             $this->_limit = '';
224
-        }
225
-        else {
222
+        } else {
226 223
             $this->_limit = " LIMIT {$limit}";
227 224
             if ($offset > 1) {
228 225
                 $this->_limit .= " OFFSET {$offset}";
Please login to merge, or discard this patch.