Passed
Branch master (fddfe5)
by y
03:08 queued 48s
created
src/DB/SQL/TextTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return Text
18 18
      */
19
-    public function hex () {
19
+    public function hex() {
20 20
         return Text::factory($this->db, "HEX({$this})");
21 21
     }
22 22
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return Num
29 29
      */
30
-    public function length () {
30
+    public function length() {
31 31
         if ($this->db->isSQLite()) {
32 32
             return Num::factory($this->db, "LENGTH(CAST({$this} AS TEXT))");
33 33
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return Text
43 43
      */
44
-    public function lower () {
44
+    public function lower() {
45 45
         return Text::factory($this->db, "LOWER({$this})");
46 46
     }
47 47
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string $substring
54 54
      * @return Num
55 55
      */
56
-    public function position (string $substring) {
56
+    public function position(string $substring) {
57 57
         $substring = $this->db->quote($substring);
58 58
         if ($this->db->isSQLite()) {
59 59
             return Num::factory($this->db, "INSTR({$this},{$substring})");
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param string $replace
71 71
      * @return Text
72 72
      */
73
-    public function replace (string $search, string $replace) {
73
+    public function replace(string $search, string $replace) {
74 74
         $search = $this->db->quote($search);
75 75
         $replace = $this->db->quote($replace);
76 76
         return Text::factory($this->db, "REPLACE({$this},{$search},{$replace})");
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return Num
83 83
      */
84
-    public function size () {
84
+    public function size() {
85 85
         if ($this->db->isSQLite()) {
86 86
             return Num::factory($this->db, "LENGTH(CAST({$this} AS BLOB))");
87 87
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param null|int $length
98 98
      * @return Text
99 99
      */
100
-    public function substr (int $start, int $length = null) {
100
+    public function substr(int $start, int $length = null) {
101 101
         if (isset($length)) {
102 102
             return Text::factory($this->db, "SUBSTR({$this},{$start},{$length})");
103 103
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @return Text
113 113
      */
114
-    public function upper () {
114
+    public function upper() {
115 115
         return Text::factory($this->db, "UPPER({$this})");
116 116
     }
117 117
 }
118 118
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/NumTrait.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @return Num
16 16
      */
17
-    public function abs () {
17
+    public function abs() {
18 18
         return Num::factory($this->db, "ABS({$this})");
19 19
     }
20 20
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @return Num
25 25
      */
26
-    public function acos () {
26
+    public function acos() {
27 27
         return Num::factory($this->db, "ACOS({$this})");
28 28
     }
29 29
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @param number|ValueInterface $arg
34 34
      * @return Num
35 35
      */
36
-    public function add ($arg) {
36
+    public function add($arg) {
37 37
         $arg = $this->db->quote($arg);
38 38
         return Num::factory($this->db, "({$this} + {$arg})");
39 39
     }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @return Num
45 45
      */
46
-    public function asin () {
46
+    public function asin() {
47 47
         return Num::factory($this->db, "ASIN({$this})");
48 48
     }
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return Num
54 54
      */
55
-    public function atan () {
55
+    public function atan() {
56 56
         return Num::factory($this->db, "ATAN({$this})");
57 57
     }
58 58
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return Num
63 63
      */
64
-    public function ceil () {
64
+    public function ceil() {
65 65
         return Num::factory($this->db, "CEIL({$this})");
66 66
     }
67 67
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      *
71 71
      * @return Num
72 72
      */
73
-    public function cos () {
73
+    public function cos() {
74 74
         return Num::factory($this->db, "COS({$this})");
75 75
     }
76 76
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return Num
83 83
      */
84
-    public function degrees () {
84
+    public function degrees() {
85 85
         return Num::factory($this->db, "DEGREES({$this})");
86 86
     }
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param number|ValueInterface $arg
92 92
      * @return Num
93 93
      */
94
-    public function div ($arg) {
94
+    public function div($arg) {
95 95
         $arg = $this->db->quote($arg);
96 96
         return Num::factory($this->db, "({$this} / {$arg})");
97 97
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @return Num
105 105
      */
106
-    public function exp () {
106
+    public function exp() {
107 107
         return Num::factory($this->db, "EXP({$this})");
108 108
     }
109 109
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return Num
114 114
      */
115
-    public function floor () {
115
+    public function floor() {
116 116
         return Num::factory($this->db, "FLOOR({$this})");
117 117
     }
118 118
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @return Predicate
123 123
      */
124
-    public function isEven () {
124
+    public function isEven() {
125 125
         return Predicate::factory($this->db, "({$this} % 2) = 0");
126 126
     }
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @return Predicate
132 132
      */
133
-    public function isNegative () {
133
+    public function isNegative() {
134 134
         return Predicate::factory($this->db, "{$this} < 0");
135 135
     }
136 136
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return Predicate
141 141
      */
142
-    public function isOdd () {
142
+    public function isOdd() {
143 143
         return Predicate::factory($this->db, "({$this} % 2) <> 0");
144 144
     }
145 145
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @return Predicate
150 150
      */
151
-    public function isPositive () {
151
+    public function isPositive() {
152 152
         return Predicate::factory($this->db, "{$this} > 0");
153 153
     }
154 154
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return Num
159 159
      */
160
-    public function ln () {
160
+    public function ln() {
161 161
         return Num::factory($this->db, "LN({$this})");
162 162
     }
163 163
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param float $base
170 170
      * @return Num
171 171
      */
172
-    public function log (float $base) {
172
+    public function log(float $base) {
173 173
         return Num::factory($this->db, "LOG({$base},{$this})");
174 174
     }
175 175
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      *
179 179
      * @return Num
180 180
      */
181
-    public function log10 () {
181
+    public function log10() {
182 182
         return Num::factory($this->db, "LOG10({$this})");
183 183
     }
184 184
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      *
188 188
      * @return Num
189 189
      */
190
-    public function log2 () {
190
+    public function log2() {
191 191
         return Num::factory($this->db, "LOG2({$this})");
192 192
     }
193 193
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      * @param float $divisor
198 198
      * @return Num
199 199
      */
200
-    public function mod (float $divisor) {
200
+    public function mod(float $divisor) {
201 201
         return Num::factory($this->db, "({$this} % {$divisor})");
202 202
     }
203 203
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @param number|ValueInterface $arg
208 208
      * @return Num
209 209
      */
210
-    public function mul ($arg) {
210
+    public function mul($arg) {
211 211
         $arg = $this->db->quote($arg);
212 212
         return Num::factory($this->db, "({$this} * {$arg})");
213 213
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param float $exponent
219 219
      * @return Num
220 220
      */
221
-    public function pow (float $exponent) {
221
+    public function pow(float $exponent) {
222 222
         return Num::factory($this->db, "POW({$this},{$exponent})");
223 223
     }
224 224
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @return Num
231 231
      */
232
-    public function radians () {
232
+    public function radians() {
233 233
         return Num::factory($this->db, "RADIANS({$this})");
234 234
     }
235 235
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @param int $decimals
240 240
      * @return Num
241 241
      */
242
-    public function round (int $decimals = 0) {
242
+    public function round(int $decimals = 0) {
243 243
         return Num::factory($this->db, "ROUND({$this},{$decimals})");
244 244
     }
245 245
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      *
249 249
      * @return Num `-1`, `0`, `1`
250 250
      */
251
-    public function sign () {
251
+    public function sign() {
252 252
         return Num::factory($this->db, "SIGN({$this})");
253 253
     }
254 254
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      *
258 258
      * @return Num
259 259
      */
260
-    public function sin () {
260
+    public function sin() {
261 261
         return Num::factory($this->db, "SIN({$this})");
262 262
     }
263 263
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      *
267 267
      * @return Num
268 268
      */
269
-    public function sqrt () {
269
+    public function sqrt() {
270 270
         return Num::factory($this->db, "SQRT({$this})");
271 271
     }
272 272
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      * @param number|ValueInterface $arg
277 277
      * @return Num
278 278
      */
279
-    public function sub ($arg) {
279
+    public function sub($arg) {
280 280
         $arg = $this->db->quote($arg);
281 281
         return Num::factory($this->db, "({$this} - {$arg})");
282 282
     }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      *
287 287
      * @return Num
288 288
      */
289
-    public function tan () {
289
+    public function tan() {
290 290
         return Num::factory($this->db, "TAN({$this})");
291 291
     }
292 292
 }
293 293
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/CastTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * @param scalar[] $values
13 13
      * @return Value
14 14
      */
15
-    public function coalesce (array $values) {
15
+    public function coalesce(array $values) {
16 16
         array_unshift($values, $this);
17 17
         $values = $this->db->quoteList($values);
18 18
         return Value::factory($this->db, "COALESCE({$values})");
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param int $to
26 26
      * @return Text
27 27
      */
28
-    public function toBase (int $from, int $to) {
28
+    public function toBase(int $from, int $to) {
29 29
         return Text::factory($this->db, "CONV({$this},{$from},{$to})");
30 30
     }
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @param int $from
36 36
      * @return Num
37 37
      */
38
-    public function toBase10 (int $from) {
38
+    public function toBase10(int $from) {
39 39
         return Num::factory($this->db, "CONV({$this},{$from},10)");
40 40
     }
41 41
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param int $from
48 48
      * @return Text
49 49
      */
50
-    public function toBase16 (int $from) {
50
+    public function toBase16(int $from) {
51 51
         return $this->toBase($from, 16);
52 52
     }
53 53
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param int $from
58 58
      * @return Text
59 59
      */
60
-    public function toBase2 (int $from) {
60
+    public function toBase2(int $from) {
61 61
         return $this->toBase($from, 2);
62 62
     }
63 63
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param int $from
68 68
      * @return Text
69 69
      */
70
-    public function toBase8 (int $from) {
70
+    public function toBase8(int $from) {
71 71
         return $this->toBase($from, 8);
72 72
     }
73 73
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      *
77 77
      * @return Num
78 78
      */
79
-    public function toFloat () {
79
+    public function toFloat() {
80 80
         if ($this->db->isSQLite()) {
81 81
             return Num::factory($this->db, "CAST({$this} AS REAL)");
82 82
         }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return Num
90 90
      */
91
-    public function toInt () {
91
+    public function toInt() {
92 92
         if ($this->db->isSQLite()) {
93 93
             return Num::factory($this->db, "CAST({$this} AS INTEGER)");
94 94
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      *
101 101
      * @return Text
102 102
      */
103
-    public function toText () {
103
+    public function toText() {
104 104
         if ($this->db->isSQLite()) {
105 105
             return Text::factory($this->db, "CAST({$this} AS TEXT)");
106 106
         }
Please login to merge, or discard this patch.
src/DB.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param string $password
71 71
      * @param array $options
72 72
      */
73
-    public function __construct ($dsn, $username = null, $password = null, array $options = []) {
73
+    public function __construct($dsn, $username = null, $password = null, array $options = []) {
74 74
         $options += [
75 75
             self::ATTR_STATEMENT_CLASS => [Statement::class, [$this]]
76 76
         ];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
         if ($this->isSQLite()) {
86 86
             // polyfill sqlite functions
87
-            $this->sqliteCreateFunctions([ // deterministic functions
87
+            $this->sqliteCreateFunctions([// deterministic functions
88 88
                 // https://www.sqlite.org/lang_mathfunc.html
89 89
                 'ACOS' => 'acos',
90 90
                 'ASIN' => 'asin',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                 'SIGN' => fn($x) => ($x > 0) - ($x < 0),
111 111
             ]);
112 112
 
113
-            $this->sqliteCreateFunctions([ // non-deterministic
113
+            $this->sqliteCreateFunctions([// non-deterministic
114 114
                 'RAND' => fn() => mt_rand(0, 1),
115 115
             ], false);
116 116
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @return string
123 123
      */
124
-    final public function __toString () {
124
+    final public function __toString() {
125 125
         return $this->driver;
126 126
     }
127 127
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return true
134 134
      */
135
-    public function beginTransaction () {
135
+    public function beginTransaction() {
136 136
         assert($this->transactions >= 0);
137 137
         if ($this->transactions === 0) {
138 138
             $this->logger->__invoke("BEGIN TRANSACTION");
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return true
154 154
      */
155
-    public function commit () {
155
+    public function commit() {
156 156
         assert($this->transactions > 0);
157 157
         if ($this->transactions === 1) {
158 158
             $this->logger->__invoke("COMMIT TRANSACTION");
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * @param string $sql
173 173
      * @return int
174 174
      */
175
-    public function exec ($sql): int {
175
+    public function exec($sql): int {
176 176
         $this->logger->__invoke($sql);
177 177
         return parent::exec($sql);
178 178
     }
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
      * @param mixed ...$args
189 189
      * @return mixed
190 190
      */
191
-    public function factory (string $class, ...$args) {
191
+    public function factory(string $class, ...$args) {
192 192
         return new $class($this, ...$args);
193 193
     }
194 194
 
195 195
     /**
196 196
      * @return string
197 197
      */
198
-    final public function getDriver (): string {
198
+    final public function getDriver(): string {
199 199
         return $this->driver;
200 200
     }
201 201
 
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
      * @param string $interface
206 206
      * @return Junction
207 207
      */
208
-    public function getJunction ($interface) {
208
+    public function getJunction($interface) {
209 209
         return $this->junctions[$interface] ??= Junction::fromInterface($this, $interface);
210 210
     }
211 211
 
212 212
     /**
213 213
      * @return Closure
214 214
      */
215
-    public function getLogger () {
215
+    public function getLogger() {
216 216
         return $this->logger;
217 217
     }
218 218
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @param string|EntityInterface $class
223 223
      * @return Record
224 224
      */
225
-    public function getRecord ($class) {
225
+    public function getRecord($class) {
226 226
         if (is_object($class)) {
227 227
             $class = get_class($class);
228 228
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param string $name
234 234
      * @return null|Table
235 235
      */
236
-    public function getTable (string $name) {
236
+    public function getTable(string $name) {
237 237
         if (!isset($this->tables[$name])) {
238 238
             if ($this->isSQLite()) {
239 239
                 $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll();
@@ -255,21 +255,21 @@  discard block
 block discarded – undo
255 255
     /**
256 256
      * @return bool
257 257
      */
258
-    final public function isMySQL (): bool {
258
+    final public function isMySQL(): bool {
259 259
         return $this->driver === 'mysql';
260 260
     }
261 261
 
262 262
     /**
263 263
      * @return bool
264 264
      */
265
-    final public function isPostgreSQL (): bool {
265
+    final public function isPostgreSQL(): bool {
266 266
         return $this->driver === 'pgsql';
267 267
     }
268 268
 
269 269
     /**
270 270
      * @return bool
271 271
      */
272
-    final public function isSQLite (): bool {
272
+    final public function isSQLite(): bool {
273 273
         return $this->driver === 'sqlite';
274 274
     }
275 275
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @param mixed $b
291 291
      * @return Predicate
292 292
      */
293
-    public function match ($a, $b) {
293
+    public function match($a, $b) {
294 294
         if ($b instanceof Closure) {
295 295
             return $b->__invoke($a, $this);
296 296
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      *
312 312
      * @return Transaction
313 313
      */
314
-    public function newTransaction () {
314
+    public function newTransaction() {
315 315
         return Transaction::factory($this);
316 316
     }
317 317
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      * @param string $table
322 322
      * @return bool
323 323
      */
324
-    final public function offsetExists ($table): bool {
324
+    final public function offsetExists($table): bool {
325 325
         return (bool)$this->getTable($table);
326 326
     }
327 327
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @param string $table
332 332
      * @return null|Table
333 333
      */
334
-    final public function offsetGet ($table) {
334
+    final public function offsetGet($table) {
335 335
         return $this->getTable($table);
336 336
     }
337 337
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
      * @param $value
341 341
      * @throws LogicException
342 342
      */
343
-    final public function offsetSet ($offset, $value) {
343
+    final public function offsetSet($offset, $value) {
344 344
         throw new LogicException('Raw table access is immutable.');
345 345
     }
346 346
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * @param $offset
349 349
      * @throws LogicException
350 350
      */
351
-    final public function offsetUnset ($offset) {
351
+    final public function offsetUnset($offset) {
352 352
         throw new LogicException('Raw table access is immutable.');
353 353
     }
354 354
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      *
358 358
      * @return Num
359 359
      */
360
-    public function pi () {
360
+    public function pi() {
361 361
         return Num::factory($this, "PI()");
362 362
     }
363 363
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      * @param array $options
369 369
      * @return Statement
370 370
      */
371
-    public function prepare ($sql, $options = []) {
371
+    public function prepare($sql, $options = []) {
372 372
         $this->logger->__invoke($sql);
373 373
         /** @var Statement $statement */
374 374
         $statement = parent::prepare($sql, $options);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      * @param array $ctorargs Optional.
385 385
      * @return Statement
386 386
      */
387
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
387
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
388 388
         $this->logger->__invoke($sql);
389 389
         /** @var Statement $statement */
390 390
         $statement = parent::query(...func_get_args());
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      * @param int $type Ignored.
403 403
      * @return string|ExpressionInterface
404 404
      */
405
-    public function quote ($value, $type = self::PARAM_STR) {
405
+    public function quote($value, $type = self::PARAM_STR) {
406 406
         if ($value instanceof ExpressionInterface) {
407 407
             return $value;
408 408
         }
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      * @param array $values
423 423
      * @return string[]
424 424
      */
425
-    public function quoteArray (array $values) {
425
+    public function quoteArray(array $values) {
426 426
         return array_map([$this, 'quote'], $values);
427 427
     }
428 428
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
      * @param array $values
433 433
      * @return string
434 434
      */
435
-    public function quoteList (array $values): string {
435
+    public function quoteList(array $values): string {
436 436
         return implode(',', $this->quoteArray($values));
437 437
     }
438 438
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
      *
442 442
      * @return Num
443 443
      */
444
-    public function rand () {
444
+    public function rand() {
445 445
         return Num::factory($this, "RAND()");
446 446
     }
447 447
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      *
453 453
      * @return true
454 454
      */
455
-    public function rollBack () {
455
+    public function rollBack() {
456 456
         assert($this->transactions > 0);
457 457
         if ($this->transactions === 1) {
458 458
             $this->logger->__invoke("ROLLBACK TRANSACTION");
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      * @param EntityInterface $entity
473 473
      * @return int ID
474 474
      */
475
-    public function save (EntityInterface $entity): int {
475
+    public function save(EntityInterface $entity): int {
476 476
         return $this->getRecord($entity)->save($entity);
477 477
     }
478 478
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
      * @param Junction $junction
482 482
      * @return $this
483 483
      */
484
-    public function setJunction (string $interface, Junction $junction) {
484
+    public function setJunction(string $interface, Junction $junction) {
485 485
         $this->junctions[$interface] = $junction;
486 486
         return $this;
487 487
     }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
      * @param Closure $logger
491 491
      * @return $this
492 492
      */
493
-    public function setLogger (Closure $logger) {
493
+    public function setLogger(Closure $logger) {
494 494
         $this->logger = $logger;
495 495
         return $this;
496 496
     }
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
      * @param Record $record
501 501
      * @return $this
502 502
      */
503
-    public function setRecord (string $class, Record $record) {
503
+    public function setRecord(string $class, Record $record) {
504 504
         $this->records[$class] = $record;
505 505
         return $this;
506 506
     }
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
      * @param callable[] $callbacks Keyed by function name.
510 510
      * @param bool $deterministic Whether the callbacks aren't random / are without side-effects.
511 511
      */
512
-    public function sqliteCreateFunctions (array $callbacks, bool $deterministic = true): void {
512
+    public function sqliteCreateFunctions(array $callbacks, bool $deterministic = true): void {
513 513
         $deterministic = $deterministic ? self::SQLITE_DETERMINISTIC : 0;
514 514
         foreach ($callbacks as $name => $callback) {
515 515
             $argc = (new ReflectionFunction($callback))->getNumberOfRequiredParameters();
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
      * @param callable $work
526 526
      * @return mixed The return value of `$work`
527 527
      */
528
-    public function transact (callable $work) {
528
+    public function transact(callable $work) {
529 529
         $transaction = $this->newTransaction();
530 530
         $return = call_user_func($work);
531 531
         $transaction->commit();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -137,8 +137,7 @@  discard block
 block discarded – undo
137 137
         if ($this->transactions === 0) {
138 138
             $this->logger->__invoke("BEGIN TRANSACTION");
139 139
             parent::beginTransaction();
140
-        }
141
-        else {
140
+        } else {
142 141
             $this->exec("SAVEPOINT SAVEPOINT_{$this->transactions}");
143 142
         }
144 143
         $this->transactions++;
@@ -157,8 +156,7 @@  discard block
 block discarded – undo
157 156
         if ($this->transactions === 1) {
158 157
             $this->logger->__invoke("COMMIT TRANSACTION");
159 158
             parent::commit();
160
-        }
161
-        else {
159
+        } else {
162 160
             $savepoint = $this->transactions - 1;
163 161
             $this->exec("RELEASE SAVEPOINT SAVEPOINT_{$savepoint}");
164 162
         }
@@ -238,8 +236,7 @@  discard block
 block discarded – undo
238 236
             if ($this->isSQLite()) {
239 237
                 $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll();
240 238
                 $cols = array_column($info, 'name');
241
-            }
242
-            else {
239
+            } else {
243 240
                 $cols = $this->query(
244 241
                     "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}"
245 242
                 )->fetchAll(self::FETCH_COLUMN);
@@ -457,8 +454,7 @@  discard block
 block discarded – undo
457 454
         if ($this->transactions === 1) {
458 455
             $this->logger->__invoke("ROLLBACK TRANSACTION");
459 456
             parent::rollBack();
460
-        }
461
-        else {
457
+        } else {
462 458
             $savepoint = $this->transactions - 1;
463 459
             $this->exec("ROLLBACK TO SAVEPOINT SAVEPOINT_{$savepoint}");
464 460
         }
Please login to merge, or discard this patch.
src/DB/Transaction.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @param DB $db
35 35
      */
36
-    public function __construct (DB $db) {
36
+    public function __construct(DB $db) {
37 37
         $this->db = $db;
38 38
         $db->beginTransaction();
39 39
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * Rolls back if the instance wasn't committed.
43 43
      */
44
-    public function __destruct () {
44
+    public function __destruct() {
45 45
         if (!$this->committed) {
46 46
             $this->db->rollBack();
47 47
         }
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @return true
56 56
      */
57
-    public function commit (): bool {
57
+    public function commit(): bool {
58 58
         return $this->committed or $this->committed = $this->db->commit();
59 59
     }
60 60
 
61 61
     /**
62 62
      * @return bool
63 63
      */
64
-    final public function wasCommitted (): bool {
64
+    final public function wasCommitted(): bool {
65 65
         return $this->committed;
66 66
     }
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.