@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return Text |
| 21 | 21 | */ |
| 22 | - public function date () { |
|
| 22 | + public function date() { |
|
| 23 | 23 | return Text::factory($this->db, $this->dateFormat('%Y-%m-%d')); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string|string[] $format Format, or formats keyed by driver name. |
| 30 | 30 | * @return Text |
| 31 | 31 | */ |
| 32 | - public function dateFormat ($format) { |
|
| 32 | + public function dateFormat($format) { |
|
| 33 | 33 | if (is_array($format)) { |
| 34 | 34 | $format = $format[$this->db->getDriver()]; |
| 35 | 35 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return Text |
| 47 | 47 | */ |
| 48 | - public function datetime () { |
|
| 48 | + public function datetime() { |
|
| 49 | 49 | return Text::factory($this->db, $this->dateFormat([ |
| 50 | 50 | 'mysql' => '%Y-%m-%d %H:%i:%S', |
| 51 | 51 | 'sqlite' => '%Y-%m-%d %H:%M:%S' |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return Num |
| 59 | 59 | */ |
| 60 | - public function day () { |
|
| 60 | + public function day() { |
|
| 61 | 61 | return Num::factory($this->db, $this->dateFormat('%d')); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return Num |
| 68 | 68 | */ |
| 69 | - public function dayOfWeek () { |
|
| 69 | + public function dayOfWeek() { |
|
| 70 | 70 | return Num::factory($this->db, $this->dateFormat('%w')); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return Num |
| 77 | 77 | */ |
| 78 | - public function dayOfYear () { |
|
| 78 | + public function dayOfYear() { |
|
| 79 | 79 | return Num::factory($this->db, $this->dateFormat('%j')); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return Num |
| 86 | 86 | */ |
| 87 | - public function hours () { |
|
| 87 | + public function hours() { |
|
| 88 | 88 | return Num::factory($this->db, $this->dateFormat('%H')); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return Num |
| 95 | 95 | */ |
| 96 | - public function minutes () { |
|
| 96 | + public function minutes() { |
|
| 97 | 97 | return Num::factory($this->db, $this->dateFormat([ |
| 98 | 98 | 'mysql' => '%i', |
| 99 | 99 | 'sqlite' => '%M' |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return Num |
| 107 | 107 | */ |
| 108 | - public function month () { |
|
| 108 | + public function month() { |
|
| 109 | 109 | return Num::factory($this->db, $this->dateFormat('%m')); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return Num |
| 116 | 116 | */ |
| 117 | - public function seconds () { |
|
| 117 | + public function seconds() { |
|
| 118 | 118 | return Num::factory($this->db, $this->dateFormat('%S')); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return Text |
| 125 | 125 | */ |
| 126 | - public function time () { |
|
| 126 | + public function time() { |
|
| 127 | 127 | return Text::factory($this->db, $this->dateFormat([ |
| 128 | 128 | 'mysql' => '%H:%i:%S', |
| 129 | 129 | 'sqlite' => '%H:%M:%S' |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return Num |
| 137 | 137 | */ |
| 138 | - public function timestamp () { |
|
| 138 | + public function timestamp() { |
|
| 139 | 139 | if ($this->db->isSQLite()) { |
| 140 | 140 | return Num::factory($this->db, "STRFTIME('%s',{$this})"); |
| 141 | 141 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return DateTime |
| 154 | 154 | */ |
| 155 | - public function toLocalTz () { |
|
| 155 | + public function toLocalTz() { |
|
| 156 | 156 | if ($this->db->isSQLite()) { |
| 157 | 157 | // docs: |
| 158 | 158 | // > The "localtime" modifier (12) assumes the time value to its left is in |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return DateTime |
| 176 | 176 | */ |
| 177 | - public function toUtc () { |
|
| 177 | + public function toUtc() { |
|
| 178 | 178 | if ($this->db->isSQLite()) { |
| 179 | 179 | // docs: |
| 180 | 180 | // > "utc" assumes that the time value to its left is in the local timezone |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return Num |
| 193 | 193 | */ |
| 194 | - public function weekOfYear () { |
|
| 194 | + public function weekOfYear() { |
|
| 195 | 195 | return Num::factory($this->db, $this->dateFormat([ |
| 196 | 196 | 'mysql' => '%U', |
| 197 | 197 | 'sqlite' => '%W' |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return Num |
| 205 | 205 | */ |
| 206 | - public function year () { |
|
| 206 | + public function year() { |
|
| 207 | 207 | return Num::factory($this->db, $this->dateFormat('%Y')); |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return DateTime |
| 121 | 121 | */ |
| 122 | - public function toDateTime () { |
|
| 122 | + public function toDateTime() { |
|
| 123 | 123 | return DateTime::factory($this->db, $this); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return Text |
| 132 | 132 | */ |
| 133 | - public function upper () { |
|
| 133 | + public function upper() { |
|
| 134 | 134 | return Text::factory($this->db, "UPPER({$this})"); |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string $file |
| 84 | 84 | * @return static |
| 85 | 85 | */ |
| 86 | - public static function fromConfig (string $connection = 'default', string $file = 'db.config.php') { |
|
| 86 | + public static function fromConfig(string $connection = 'default', string $file = 'db.config.php') { |
|
| 87 | 87 | $config = (include "{$file}")[$connection]; |
| 88 | 88 | $args = [ |
| 89 | 89 | $config['dsn'], |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | * @param int|array|Countable $count |
| 104 | 104 | * @return ExpressionInterface[] |
| 105 | 105 | */ |
| 106 | - public static function marks ($count): array { |
|
| 106 | + public static function marks($count): array { |
|
| 107 | 107 | static $mark; |
| 108 | 108 | $mark ??= new class implements ExpressionInterface { |
| 109 | 109 | |
| 110 | - public function __toString () { |
|
| 110 | + public function __toString() { |
|
| 111 | 111 | return '?'; |
| 112 | 112 | } |
| 113 | 113 | }; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param string[] $columns |
| 126 | 126 | * @return string[] `["column" => ":column"]` |
| 127 | 127 | */ |
| 128 | - public static function slots (array $columns): array { |
|
| 128 | + public static function slots(array $columns): array { |
|
| 129 | 129 | return array_combine($columns, array_map(function(string $column) { |
| 130 | 130 | return ':' . str_replace('.', '__', $column); |
| 131 | 131 | }, $columns)); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string[] $columns |
| 136 | 136 | * @return string[] `["column" => "column=:column"]` |
| 137 | 137 | */ |
| 138 | - public static function slotsEqual (array $columns): array { |
|
| 138 | + public static function slotsEqual(array $columns): array { |
|
| 139 | 139 | $slots = static::slots($columns); |
| 140 | 140 | foreach ($slots as $column => $slot) { |
| 141 | 141 | $slots[$column] = "{$column} = {$slot}"; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $password |
| 154 | 154 | * @param array $options |
| 155 | 155 | */ |
| 156 | - public function __construct ($dsn, $username = null, $password = null, array $options = []) { |
|
| 156 | + public function __construct($dsn, $username = null, $password = null, array $options = []) { |
|
| 157 | 157 | $options[self::ATTR_STATEMENT_CLASS] ??= [Statement::class, [$this]]; |
| 158 | 158 | parent::__construct($dsn, $username, $password, $options); |
| 159 | 159 | $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | elseif ($this->isSQLite()) { |
| 171 | 171 | // polyfill sqlite functions |
| 172 | - $this->sqliteCreateFunctions([ // deterministic functions |
|
| 172 | + $this->sqliteCreateFunctions([// deterministic functions |
|
| 173 | 173 | // https://www.sqlite.org/lang_mathfunc.html |
| 174 | 174 | 'ACOS' => 'acos', |
| 175 | 175 | 'ASIN' => 'asin', |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | 'SIGN' => fn($x) => ($x > 0) - ($x < 0), |
| 196 | 196 | ]); |
| 197 | 197 | |
| 198 | - $this->sqliteCreateFunctions([ // non-deterministic |
|
| 198 | + $this->sqliteCreateFunctions([// non-deterministic |
|
| 199 | 199 | 'RAND' => fn() => mt_rand() / mt_getrandmax(), |
| 200 | 200 | ], false); |
| 201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return string |
| 208 | 208 | */ |
| 209 | - final public function __toString () { |
|
| 209 | + final public function __toString() { |
|
| 210 | 210 | return $this->driver; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return true |
| 219 | 219 | */ |
| 220 | - public function beginTransaction () { |
|
| 220 | + public function beginTransaction() { |
|
| 221 | 221 | assert($this->transactions >= 0); |
| 222 | 222 | if ($this->transactions === 0) { |
| 223 | 223 | $this->logger->__invoke("BEGIN TRANSACTION"); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return true |
| 239 | 239 | */ |
| 240 | - public function commit () { |
|
| 240 | + public function commit() { |
|
| 241 | 241 | assert($this->transactions > 0); |
| 242 | 242 | if ($this->transactions === 1) { |
| 243 | 243 | $this->logger->__invoke("COMMIT TRANSACTION"); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @param string $sql |
| 258 | 258 | * @return int |
| 259 | 259 | */ |
| 260 | - public function exec ($sql): int { |
|
| 260 | + public function exec($sql): int { |
|
| 261 | 261 | $this->logger->__invoke($sql); |
| 262 | 262 | return parent::exec($sql); |
| 263 | 263 | } |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | * @param mixed ...$args |
| 274 | 274 | * @return mixed |
| 275 | 275 | */ |
| 276 | - public function factory (string $class, ...$args) { |
|
| 276 | + public function factory(string $class, ...$args) { |
|
| 277 | 277 | return new $class($this, ...$args); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | - final public function getDriver (): string { |
|
| 283 | + final public function getDriver(): string { |
|
| 284 | 284 | return $this->driver; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | * @param string $interface |
| 291 | 291 | * @return Junction |
| 292 | 292 | */ |
| 293 | - public function getJunction ($interface) { |
|
| 293 | + public function getJunction($interface) { |
|
| 294 | 294 | return $this->junctions[$interface] ??= Junction::fromInterface($this, $interface); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @return Closure |
| 299 | 299 | */ |
| 300 | - public function getLogger () { |
|
| 300 | + public function getLogger() { |
|
| 301 | 301 | return $this->logger; |
| 302 | 302 | } |
| 303 | 303 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @param string $dir |
| 306 | 306 | * @return Migrator |
| 307 | 307 | */ |
| 308 | - public function getMigrator () { |
|
| 308 | + public function getMigrator() { |
|
| 309 | 309 | return Migrator::factory($this, $this->migrations); |
| 310 | 310 | } |
| 311 | 311 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param string|EntityInterface $class |
| 316 | 316 | * @return Record |
| 317 | 317 | */ |
| 318 | - public function getRecord ($class) { |
|
| 318 | + public function getRecord($class) { |
|
| 319 | 319 | if (is_object($class)) { |
| 320 | 320 | $class = get_class($class); |
| 321 | 321 | } |
@@ -325,28 +325,28 @@ discard block |
||
| 325 | 325 | /** |
| 326 | 326 | * @return Schema |
| 327 | 327 | */ |
| 328 | - public function getSchema () { |
|
| 328 | + public function getSchema() { |
|
| 329 | 329 | return $this->schema; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | 333 | * @return bool |
| 334 | 334 | */ |
| 335 | - final public function isMySQL (): bool { |
|
| 335 | + final public function isMySQL(): bool { |
|
| 336 | 336 | return $this->driver === 'mysql'; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | 340 | * @return bool |
| 341 | 341 | */ |
| 342 | - final public function isPostgreSQL (): bool { |
|
| 342 | + final public function isPostgreSQL(): bool { |
|
| 343 | 343 | return $this->driver === 'pgsql'; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * @return bool |
| 348 | 348 | */ |
| 349 | - final public function isSQLite (): bool { |
|
| 349 | + final public function isSQLite(): bool { |
|
| 350 | 350 | return $this->driver === 'sqlite'; |
| 351 | 351 | } |
| 352 | 352 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @param mixed $b |
| 370 | 370 | * @return Predicate |
| 371 | 371 | */ |
| 372 | - public function match ($a, $b) { |
|
| 372 | + public function match($a, $b) { |
|
| 373 | 373 | if ($b instanceof Closure) { |
| 374 | 374 | return $b->__invoke($a, $this); |
| 375 | 375 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return Transaction |
| 392 | 392 | */ |
| 393 | - public function newTransaction () { |
|
| 393 | + public function newTransaction() { |
|
| 394 | 394 | return Transaction::factory($this); |
| 395 | 395 | } |
| 396 | 396 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @param string $table |
| 401 | 401 | * @return bool |
| 402 | 402 | */ |
| 403 | - final public function offsetExists ($table): bool { |
|
| 403 | + final public function offsetExists($table): bool { |
|
| 404 | 404 | return (bool)$this->offsetGet($table); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @param string $table |
| 411 | 411 | * @return null|Table |
| 412 | 412 | */ |
| 413 | - public function offsetGet ($table) { |
|
| 413 | + public function offsetGet($table) { |
|
| 414 | 414 | return $this->schema->getTable($table); |
| 415 | 415 | } |
| 416 | 416 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @param $value |
| 420 | 420 | * @throws LogicException |
| 421 | 421 | */ |
| 422 | - final public function offsetSet ($offset, $value) { |
|
| 422 | + final public function offsetSet($offset, $value) { |
|
| 423 | 423 | throw new LogicException('The schema cannot be altered this way.'); |
| 424 | 424 | } |
| 425 | 425 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @param $offset |
| 428 | 428 | * @throws LogicException |
| 429 | 429 | */ |
| 430 | - final public function offsetUnset ($offset) { |
|
| 430 | + final public function offsetUnset($offset) { |
|
| 431 | 431 | throw new LogicException('The schema cannot be altered this way.'); |
| 432 | 432 | } |
| 433 | 433 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @return Num |
| 438 | 438 | */ |
| 439 | - public function pi () { |
|
| 439 | + public function pi() { |
|
| 440 | 440 | return Num::factory($this, "PI()"); |
| 441 | 441 | } |
| 442 | 442 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @param array $options |
| 448 | 448 | * @return Statement |
| 449 | 449 | */ |
| 450 | - public function prepare ($sql, $options = []) { |
|
| 450 | + public function prepare($sql, $options = []) { |
|
| 451 | 451 | $this->logger->__invoke($sql); |
| 452 | 452 | /** @var Statement $statement */ |
| 453 | 453 | $statement = parent::prepare($sql, $options); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param array $ctorargs Optional. |
| 464 | 464 | * @return Statement |
| 465 | 465 | */ |
| 466 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
| 466 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
| 467 | 467 | $this->logger->__invoke($sql); |
| 468 | 468 | /** @var Statement $statement */ |
| 469 | 469 | $statement = parent::query(...func_get_args()); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * @param int $type Ignored. |
| 482 | 482 | * @return string|ExpressionInterface |
| 483 | 483 | */ |
| 484 | - public function quote ($value, $type = self::PARAM_STR) { |
|
| 484 | + public function quote($value, $type = self::PARAM_STR) { |
|
| 485 | 485 | if ($value instanceof ExpressionInterface) { |
| 486 | 486 | return $value; |
| 487 | 487 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param array $values |
| 502 | 502 | * @return string[] |
| 503 | 503 | */ |
| 504 | - public function quoteArray (array $values) { |
|
| 504 | + public function quoteArray(array $values) { |
|
| 505 | 505 | return array_map([$this, 'quote'], $values); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * @param array $values |
| 512 | 512 | * @return string |
| 513 | 513 | */ |
| 514 | - public function quoteList (array $values): string { |
|
| 514 | + public function quoteList(array $values): string { |
|
| 515 | 515 | return implode(',', $this->quoteArray($values)); |
| 516 | 516 | } |
| 517 | 517 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * |
| 521 | 521 | * @return Num |
| 522 | 522 | */ |
| 523 | - public function rand () { |
|
| 523 | + public function rand() { |
|
| 524 | 524 | return Num::factory($this, "RAND()"); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * |
| 532 | 532 | * @return true |
| 533 | 533 | */ |
| 534 | - public function rollBack () { |
|
| 534 | + public function rollBack() { |
|
| 535 | 535 | assert($this->transactions > 0); |
| 536 | 536 | if ($this->transactions === 1) { |
| 537 | 537 | $this->logger->__invoke("ROLLBACK TRANSACTION"); |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * @param EntityInterface $entity |
| 552 | 552 | * @return int ID |
| 553 | 553 | */ |
| 554 | - public function save (EntityInterface $entity): int { |
|
| 554 | + public function save(EntityInterface $entity): int { |
|
| 555 | 555 | return $this->getRecord($entity)->save($entity); |
| 556 | 556 | } |
| 557 | 557 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @param Junction $junction |
| 561 | 561 | * @return $this |
| 562 | 562 | */ |
| 563 | - public function setJunction (string $interface, Junction $junction) { |
|
| 563 | + public function setJunction(string $interface, Junction $junction) { |
|
| 564 | 564 | $this->junctions[$interface] = $junction; |
| 565 | 565 | return $this; |
| 566 | 566 | } |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param Closure $logger |
| 570 | 570 | * @return $this |
| 571 | 571 | */ |
| 572 | - public function setLogger (Closure $logger) { |
|
| 572 | + public function setLogger(Closure $logger) { |
|
| 573 | 573 | $this->logger = $logger; |
| 574 | 574 | return $this; |
| 575 | 575 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | * @param Record $record |
| 580 | 580 | * @return $this |
| 581 | 581 | */ |
| 582 | - public function setRecord (string $class, Record $record) { |
|
| 582 | + public function setRecord(string $class, Record $record) { |
|
| 583 | 583 | $this->records[$class] = $record; |
| 584 | 584 | return $this; |
| 585 | 585 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @param callable[] $callbacks Keyed by function name. |
| 589 | 589 | * @param bool $deterministic Whether the callbacks aren't random / are without side-effects. |
| 590 | 590 | */ |
| 591 | - public function sqliteCreateFunctions (array $callbacks, bool $deterministic = true): void { |
|
| 591 | + public function sqliteCreateFunctions(array $callbacks, bool $deterministic = true): void { |
|
| 592 | 592 | $deterministic = $deterministic ? self::SQLITE_DETERMINISTIC : 0; |
| 593 | 593 | foreach ($callbacks as $name => $callback) { |
| 594 | 594 | $argc = (new ReflectionFunction($callback))->getNumberOfRequiredParameters(); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param callable $work |
| 605 | 605 | * @return mixed The return value of `$work` |
| 606 | 606 | */ |
| 607 | - public function transact (callable $work) { |
|
| 607 | + public function transact(callable $work) { |
|
| 608 | 608 | $transaction = $this->newTransaction(); |
| 609 | 609 | $return = call_user_func($work); |
| 610 | 610 | $transaction->commit(); |
@@ -166,8 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | if ($this->isMySQL()) { |
| 168 | 168 | $this->exec("SET time_zone = 'UTC'"); |
| 169 | - } |
|
| 170 | - elseif ($this->isSQLite()) { |
|
| 169 | + } elseif ($this->isSQLite()) { |
|
| 171 | 170 | // polyfill sqlite functions |
| 172 | 171 | $this->sqliteCreateFunctions([ // deterministic functions |
| 173 | 172 | // https://www.sqlite.org/lang_mathfunc.html |
@@ -222,8 +221,7 @@ discard block |
||
| 222 | 221 | if ($this->transactions === 0) { |
| 223 | 222 | $this->logger->__invoke("BEGIN TRANSACTION"); |
| 224 | 223 | parent::beginTransaction(); |
| 225 | - } |
|
| 226 | - else { |
|
| 224 | + } else { |
|
| 227 | 225 | $this->exec("SAVEPOINT SAVEPOINT_{$this->transactions}"); |
| 228 | 226 | } |
| 229 | 227 | $this->transactions++; |
@@ -242,8 +240,7 @@ discard block |
||
| 242 | 240 | if ($this->transactions === 1) { |
| 243 | 241 | $this->logger->__invoke("COMMIT TRANSACTION"); |
| 244 | 242 | parent::commit(); |
| 245 | - } |
|
| 246 | - else { |
|
| 243 | + } else { |
|
| 247 | 244 | $savepoint = $this->transactions - 1; |
| 248 | 245 | $this->exec("RELEASE SAVEPOINT SAVEPOINT_{$savepoint}"); |
| 249 | 246 | } |
@@ -536,8 +533,7 @@ discard block |
||
| 536 | 533 | if ($this->transactions === 1) { |
| 537 | 534 | $this->logger->__invoke("ROLLBACK TRANSACTION"); |
| 538 | 535 | parent::rollBack(); |
| 539 | - } |
|
| 540 | - else { |
|
| 536 | + } else { |
|
| 541 | 537 | $savepoint = $this->transactions - 1; |
| 542 | 538 | $this->exec("ROLLBACK TO SAVEPOINT SAVEPOINT_{$savepoint}"); |
| 543 | 539 | } |