@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param string $password |
| 63 | 63 | * @param array $options |
| 64 | 64 | */ |
| 65 | - public function __construct ($dsn, $username = null, $password = null, array $options = []) { |
|
| 65 | + public function __construct($dsn, $username = null, $password = null, array $options = []) { |
|
| 66 | 66 | $options += [ |
| 67 | 67 | self::ATTR_STATEMENT_CLASS => [Statement::class, [$this]] |
| 68 | 68 | ]; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | if ($this->isSQLite()) { |
| 78 | 78 | // polyfill sqlite functions |
| 79 | - $this->sqliteCreateFunctions([ // deterministic functions |
|
| 79 | + $this->sqliteCreateFunctions([// deterministic functions |
|
| 80 | 80 | // https://www.sqlite.org/lang_mathfunc.html |
| 81 | 81 | 'ACOS' => 'acos', |
| 82 | 82 | 'ASIN' => 'asin', |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | 'SIGN' => fn($x) => ($x > 0) - ($x < 0), |
| 103 | 103 | ]); |
| 104 | 104 | |
| 105 | - $this->sqliteCreateFunctions([ // non-deterministic |
|
| 105 | + $this->sqliteCreateFunctions([// non-deterministic |
|
| 106 | 106 | 'RAND' => fn() => mt_rand(0, 1), |
| 107 | 107 | ], false); |
| 108 | 108 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string |
| 115 | 115 | */ |
| 116 | - final public function __toString () { |
|
| 116 | + final public function __toString() { |
|
| 117 | 117 | return $this->driver; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param string $sql |
| 124 | 124 | * @return int |
| 125 | 125 | */ |
| 126 | - public function exec ($sql): int { |
|
| 126 | + public function exec($sql): int { |
|
| 127 | 127 | $this->logger->__invoke($sql); |
| 128 | 128 | return parent::exec($sql); |
| 129 | 129 | } |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | * @param mixed ...$args |
| 140 | 140 | * @return mixed |
| 141 | 141 | */ |
| 142 | - public function factory (string $class, ...$args) { |
|
| 142 | + public function factory(string $class, ...$args) { |
|
| 143 | 143 | return new $class($this, ...$args); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - final public function getDriver (): string { |
|
| 149 | + final public function getDriver(): string { |
|
| 150 | 150 | return $this->driver; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | * @param string $interface |
| 157 | 157 | * @return Junction |
| 158 | 158 | */ |
| 159 | - public function getJunction ($interface) { |
|
| 159 | + public function getJunction($interface) { |
|
| 160 | 160 | return $this->junctions[$interface] ??= Junction::fromInterface($this, $interface); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * @return Closure |
| 165 | 165 | */ |
| 166 | - public function getLogger () { |
|
| 166 | + public function getLogger() { |
|
| 167 | 167 | return $this->logger; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @param string|EntityInterface $class |
| 174 | 174 | * @return Record |
| 175 | 175 | */ |
| 176 | - public function getRecord ($class) { |
|
| 176 | + public function getRecord($class) { |
|
| 177 | 177 | if (is_object($class)) { |
| 178 | 178 | $class = get_class($class); |
| 179 | 179 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param string $name |
| 185 | 185 | * @return null|Table |
| 186 | 186 | */ |
| 187 | - public function getTable (string $name) { |
|
| 187 | + public function getTable(string $name) { |
|
| 188 | 188 | if (!isset($this->tables[$name])) { |
| 189 | 189 | if ($this->isSQLite()) { |
| 190 | 190 | $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll(); |
@@ -206,21 +206,21 @@ discard block |
||
| 206 | 206 | /** |
| 207 | 207 | * @return bool |
| 208 | 208 | */ |
| 209 | - final public function isMySQL (): bool { |
|
| 209 | + final public function isMySQL(): bool { |
|
| 210 | 210 | return $this->driver === 'mysql'; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * @return bool |
| 215 | 215 | */ |
| 216 | - final public function isPostgreSQL (): bool { |
|
| 216 | + final public function isPostgreSQL(): bool { |
|
| 217 | 217 | return $this->driver === 'pgsql'; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * @return bool |
| 222 | 222 | */ |
| 223 | - final public function isSQLite (): bool { |
|
| 223 | + final public function isSQLite(): bool { |
|
| 224 | 224 | return $this->driver === 'sqlite'; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param mixed $b |
| 242 | 242 | * @return Predicate |
| 243 | 243 | */ |
| 244 | - public function match ($a, $b) { |
|
| 244 | + public function match($a, $b) { |
|
| 245 | 245 | if ($b instanceof Closure) { |
| 246 | 246 | return $b->__invoke($a, $this); |
| 247 | 247 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string $table |
| 264 | 264 | * @return bool |
| 265 | 265 | */ |
| 266 | - final public function offsetExists ($table): bool { |
|
| 266 | + final public function offsetExists($table): bool { |
|
| 267 | 267 | return (bool)$this->getTable($table); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $table |
| 274 | 274 | * @return null|Table |
| 275 | 275 | */ |
| 276 | - final public function offsetGet ($table) { |
|
| 276 | + final public function offsetGet($table) { |
|
| 277 | 277 | return $this->getTable($table); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param $value |
| 283 | 283 | * @throws LogicException |
| 284 | 284 | */ |
| 285 | - final public function offsetSet ($offset, $value) { |
|
| 285 | + final public function offsetSet($offset, $value) { |
|
| 286 | 286 | throw new LogicException('Raw table access is immutable.'); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param $offset |
| 291 | 291 | * @throws LogicException |
| 292 | 292 | */ |
| 293 | - final public function offsetUnset ($offset) { |
|
| 293 | + final public function offsetUnset($offset) { |
|
| 294 | 294 | throw new LogicException('Raw table access is immutable.'); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @return Num |
| 301 | 301 | */ |
| 302 | - public function pi () { |
|
| 302 | + public function pi() { |
|
| 303 | 303 | return Num::factory($this, "PI()"); |
| 304 | 304 | } |
| 305 | 305 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @param array $options |
| 311 | 311 | * @return Statement |
| 312 | 312 | */ |
| 313 | - public function prepare ($sql, $options = []) { |
|
| 313 | + public function prepare($sql, $options = []) { |
|
| 314 | 314 | $this->logger->__invoke($sql); |
| 315 | 315 | /** @var Statement $statement */ |
| 316 | 316 | $statement = parent::prepare($sql, $options); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param array $ctorargs Optional. |
| 327 | 327 | * @return Statement |
| 328 | 328 | */ |
| 329 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
| 329 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
| 330 | 330 | $this->logger->__invoke($sql); |
| 331 | 331 | /** @var Statement $statement */ |
| 332 | 332 | $statement = parent::query(...func_get_args()); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @param int $type Ignored. |
| 345 | 345 | * @return string|ExpressionInterface |
| 346 | 346 | */ |
| 347 | - public function quote ($value, $type = self::PARAM_STR) { |
|
| 347 | + public function quote($value, $type = self::PARAM_STR) { |
|
| 348 | 348 | if ($value instanceof ExpressionInterface) { |
| 349 | 349 | return $value; |
| 350 | 350 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param array $values |
| 365 | 365 | * @return string[] |
| 366 | 366 | */ |
| 367 | - public function quoteArray (array $values) { |
|
| 367 | + public function quoteArray(array $values) { |
|
| 368 | 368 | return array_map([$this, 'quote'], $values); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param array $values |
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | - public function quoteList (array $values): string { |
|
| 377 | + public function quoteList(array $values): string { |
|
| 378 | 378 | return implode(',', $this->quoteArray($values)); |
| 379 | 379 | } |
| 380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * |
| 384 | 384 | * @return Num |
| 385 | 385 | */ |
| 386 | - public function rand () { |
|
| 386 | + public function rand() { |
|
| 387 | 387 | return Num::factory($this, "RAND()"); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @param EntityInterface $entity |
| 394 | 394 | * @return int ID |
| 395 | 395 | */ |
| 396 | - public function save (EntityInterface $entity): int { |
|
| 396 | + public function save(EntityInterface $entity): int { |
|
| 397 | 397 | return $this->getRecord($entity)->save($entity); |
| 398 | 398 | } |
| 399 | 399 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @param Junction $junction |
| 403 | 403 | * @return $this |
| 404 | 404 | */ |
| 405 | - public function setJunction (string $interface, Junction $junction) { |
|
| 405 | + public function setJunction(string $interface, Junction $junction) { |
|
| 406 | 406 | $this->junctions[$interface] = $junction; |
| 407 | 407 | return $this; |
| 408 | 408 | } |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @param Closure $logger |
| 412 | 412 | * @return $this |
| 413 | 413 | */ |
| 414 | - public function setLogger (Closure $logger) { |
|
| 414 | + public function setLogger(Closure $logger) { |
|
| 415 | 415 | $this->logger = $logger; |
| 416 | 416 | return $this; |
| 417 | 417 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | * @param Record $record |
| 422 | 422 | * @return $this |
| 423 | 423 | */ |
| 424 | - public function setRecord (string $class, Record $record) { |
|
| 424 | + public function setRecord(string $class, Record $record) { |
|
| 425 | 425 | $this->records[$class] = $record; |
| 426 | 426 | return $this; |
| 427 | 427 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * @param callable[] $callbacks Keyed by function name. |
| 431 | 431 | * @param bool $deterministic Whether the callbacks aren't random / are without side-effects. |
| 432 | 432 | */ |
| 433 | - public function sqliteCreateFunctions (array $callbacks, bool $deterministic = true): void { |
|
| 433 | + public function sqliteCreateFunctions(array $callbacks, bool $deterministic = true): void { |
|
| 434 | 434 | $deterministic = $deterministic ? self::SQLITE_DETERMINISTIC : 0; |
| 435 | 435 | foreach ($callbacks as $name => $callback) { |
| 436 | 436 | $argc = (new ReflectionFunction($callback))->getNumberOfRequiredParameters(); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param string|Select $table |
| 117 | 117 | * @param string[] $columns |
| 118 | 118 | */ |
| 119 | - public function __construct (DB $db, $table, array $columns) { |
|
| 119 | + public function __construct(DB $db, $table, array $columns) { |
|
| 120 | 120 | parent::__construct($db); |
| 121 | 121 | if ($table instanceof Select) { |
| 122 | 122 | $this->table = $table->toSubquery(); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param array $args |
| 137 | 137 | * @return Statement |
| 138 | 138 | */ |
| 139 | - public function __invoke (array $args = []) { |
|
| 139 | + public function __invoke(array $args = []) { |
|
| 140 | 140 | return $this->execute($args); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return string |
| 147 | 147 | */ |
| 148 | - final public function __toString () { |
|
| 148 | + final public function __toString() { |
|
| 149 | 149 | return $this->alias; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param array $args Execution arguments. |
| 156 | 156 | * @return int |
| 157 | 157 | */ |
| 158 | - public function count (array $args = []): int { |
|
| 158 | + public function count(array $args = []): int { |
|
| 159 | 159 | $clone = clone $this; |
| 160 | 160 | $clone->_columns = 'COUNT(*)'; |
| 161 | 161 | $clone->_order = ''; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param array $args |
| 169 | 169 | * @return Statement |
| 170 | 170 | */ |
| 171 | - public function execute (array $args = []) { |
|
| 171 | + public function execute(array $args = []) { |
|
| 172 | 172 | if (empty($args)) { |
| 173 | 173 | return $this->db->query($this->toSql()); |
| 174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param array $args Execution arguments. |
| 184 | 184 | * @return array |
| 185 | 185 | */ |
| 186 | - public function getAll (array $args = []): array { |
|
| 186 | + public function getAll(array $args = []): array { |
|
| 187 | 187 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $args Execution arguments. |
| 197 | 197 | * @return Generator |
| 198 | 198 | */ |
| 199 | - public function getEach (array $args = []) { |
|
| 199 | + public function getEach(array $args = []) { |
|
| 200 | 200 | yield from $this->fetcher->__invoke($this->execute($args)); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param array $args |
| 209 | 209 | * @return mixed |
| 210 | 210 | */ |
| 211 | - public function getFirst (array $args = []) { |
|
| 211 | + public function getFirst(array $args = []) { |
|
| 212 | 212 | return $this->getEach($args)->current(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return Generator |
| 221 | 221 | */ |
| 222 | - public function getIterator () { |
|
| 222 | + public function getIterator() { |
|
| 223 | 223 | yield from $this->getEach(); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return mixed |
| 231 | 231 | */ |
| 232 | - public function getResult (array $args = []) { |
|
| 232 | + public function getResult(array $args = []) { |
|
| 233 | 233 | return $this->execute($args)->fetchColumn(); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string $column |
| 240 | 240 | * @return $this |
| 241 | 241 | */ |
| 242 | - public function group (string $column) { |
|
| 242 | + public function group(string $column) { |
|
| 243 | 243 | if (!strlen($this->_group)) { |
| 244 | 244 | $this->_group = " GROUP BY {$column}"; |
| 245 | 245 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param string $condition |
| 256 | 256 | * @return $this |
| 257 | 257 | */ |
| 258 | - public function having (string $condition) { |
|
| 258 | + public function having(string $condition) { |
|
| 259 | 259 | if (!strlen($this->_having)) { |
| 260 | 260 | $this->_having = " HAVING {$condition}"; |
| 261 | 261 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param bool $all |
| 273 | 273 | * @return $this |
| 274 | 274 | */ |
| 275 | - public function intersect (Select $select, $all = false) { |
|
| 275 | + public function intersect(Select $select, $all = false) { |
|
| 276 | 276 | $select = clone $select; |
| 277 | 277 | $select->_order = ''; |
| 278 | 278 | $select->_limit = ''; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @return Predicate |
| 292 | 292 | */ |
| 293 | - public function isEmpty () { |
|
| 293 | + public function isEmpty() { |
|
| 294 | 294 | return Predicate::factory($this->db, "NOT EXISTS ({$this->toSql()})"); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @return Predicate |
| 301 | 301 | */ |
| 302 | - public function isNotEmpty () { |
|
| 302 | + public function isNotEmpty() { |
|
| 303 | 303 | return Predicate::factory($this->db, "EXISTS ({$this->toSql()})"); |
| 304 | 304 | } |
| 305 | 305 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param string $type |
| 312 | 312 | * @return $this |
| 313 | 313 | */ |
| 314 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
| 314 | + public function join($table, string $condition, string $type = 'INNER') { |
|
| 315 | 315 | if ($table instanceof Select) { |
| 316 | 316 | $table = $table->toSubquery(); |
| 317 | 317 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param int $offset |
| 327 | 327 | * @return $this |
| 328 | 328 | */ |
| 329 | - public function limit (int $limit, int $offset = 0) { |
|
| 329 | + public function limit(int $limit, int $offset = 0) { |
|
| 330 | 330 | if ($limit == 0) { |
| 331 | 331 | $this->_limit = ''; |
| 332 | 332 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @param int|string $ref Ordinal or reference name. |
| 346 | 346 | * @return null|Column |
| 347 | 347 | */ |
| 348 | - public function offsetGet ($ref) { |
|
| 348 | + public function offsetGet($ref) { |
|
| 349 | 349 | if (is_int($ref)) { |
| 350 | 350 | return current(array_slice($this->refs, $ref, 1)) ?: null; |
| 351 | 351 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * @param string $order |
| 359 | 359 | * @return $this |
| 360 | 360 | */ |
| 361 | - public function order (string $order) { |
|
| 361 | + public function order(string $order) { |
|
| 362 | 362 | if (strlen($order)) { |
| 363 | 363 | $order = " ORDER BY {$order}"; |
| 364 | 364 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | /** |
| 370 | 370 | * @return Statement |
| 371 | 371 | */ |
| 372 | - public function prepare () { |
|
| 372 | + public function prepare() { |
|
| 373 | 373 | return $this->db->prepare($this->toSql()); |
| 374 | 374 | } |
| 375 | 375 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @param string $alias |
| 378 | 378 | * @return $this |
| 379 | 379 | */ |
| 380 | - public function setAlias (string $alias) { |
|
| 380 | + public function setAlias(string $alias) { |
|
| 381 | 381 | $this->alias = $alias; |
| 382 | 382 | foreach ($this->refs as $k => $column) { |
| 383 | 383 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @param string[] $expressions Keyed by alias if applicable. |
| 396 | 396 | * @return $this |
| 397 | 397 | */ |
| 398 | - public function setColumns (array $expressions) { |
|
| 398 | + public function setColumns(array $expressions) { |
|
| 399 | 399 | $this->refs = []; |
| 400 | 400 | $_columns = []; |
| 401 | 401 | foreach ($expressions as $alias => $expr) { |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @param Closure $fetcher |
| 421 | 421 | * @return $this |
| 422 | 422 | */ |
| 423 | - public function setFetcher (Closure $fetcher) { |
|
| 423 | + public function setFetcher(Closure $fetcher) { |
|
| 424 | 424 | $this->fetcher = $fetcher; |
| 425 | 425 | return $this; |
| 426 | 426 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * |
| 431 | 431 | * @return string |
| 432 | 432 | */ |
| 433 | - public function toSql (): string { |
|
| 433 | + public function toSql(): string { |
|
| 434 | 434 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
| 435 | 435 | $sql .= $this->_join; |
| 436 | 436 | $sql .= $this->_where; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * |
| 448 | 448 | * @return string |
| 449 | 449 | */ |
| 450 | - public function toSubquery (): string { |
|
| 450 | + public function toSubquery(): string { |
|
| 451 | 451 | return "({$this->toSql()}) AS {$this->alias}"; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param bool $all |
| 459 | 459 | * @return $this |
| 460 | 460 | */ |
| 461 | - public function union (Select $select, $all = false) { |
|
| 461 | + public function union(Select $select, $all = false) { |
|
| 462 | 462 | $select = clone $select; |
| 463 | 463 | $select->_order = ''; |
| 464 | 464 | $select->_limit = ''; |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @param string $condition |
| 478 | 478 | * @return $this |
| 479 | 479 | */ |
| 480 | - public function where (string $condition) { |
|
| 480 | + public function where(string $condition) { |
|
| 481 | 481 | if (!strlen($this->_where)) { |
| 482 | 482 | $this->_where = " WHERE {$condition}"; |
| 483 | 483 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -12,7 +12,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |