@@ -12,7 +12,7 @@ |
||
| 12 | 12 | use ComparisonTrait; |
| 13 | 13 | use AggregateTrait; |
| 14 | 14 | |
| 15 | - public function __construct (DB $db, string $expression) { |
|
| 15 | + public function __construct(DB $db, string $expression) { |
|
| 16 | 16 | $this->db = $db; |
| 17 | 17 | parent::__construct($expression); |
| 18 | 18 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param string $aggregate `ALL|DISTINCT` |
| 21 | 21 | * @return Numeric |
| 22 | 22 | */ |
| 23 | - public function getAvg ($aggregate = 'ALL') { |
|
| 23 | + public function getAvg($aggregate = 'ALL') { |
|
| 24 | 24 | return new Numeric($this->db, "AVG({$aggregate} {$this})"); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $delimiter |
| 31 | 31 | * @return Text |
| 32 | 32 | */ |
| 33 | - public function getConcat (string $delimiter = ',') { |
|
| 33 | + public function getConcat(string $delimiter = ',') { |
|
| 34 | 34 | $delimiter = $this->db->quote($delimiter); |
| 35 | 35 | switch ($this->db->getDriver()) { |
| 36 | 36 | case 'sqlite': |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param string $aggregate `ALL|DISTINCT` |
| 47 | 47 | * @return Numeric |
| 48 | 48 | */ |
| 49 | - public function getCount ($aggregate = 'ALL') { |
|
| 49 | + public function getCount($aggregate = 'ALL') { |
|
| 50 | 50 | return new Numeric($this->db, "COUNT({$aggregate} {$this})"); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return Numeric |
| 57 | 57 | */ |
| 58 | - public function getMax () { |
|
| 58 | + public function getMax() { |
|
| 59 | 59 | return new Numeric($this->db, "MAX({$this})"); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return Numeric |
| 66 | 66 | */ |
| 67 | - public function getMin () { |
|
| 67 | + public function getMin() { |
|
| 68 | 68 | return new Numeric($this->db, "MIN({$this})"); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param string $aggregate `ALL|DISTINCT` |
| 75 | 75 | * @return Numeric |
| 76 | 76 | */ |
| 77 | - public function getSum ($aggregate = 'ALL') { |
|
| 77 | + public function getSum($aggregate = 'ALL') { |
|
| 78 | 78 | return new Numeric($this->db, "SUM({$aggregate} {$this})"); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -7,6 +7,6 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | interface ExpressionInterface { |
| 9 | 9 | |
| 10 | - public function __toString (); |
|
| 10 | + public function __toString(); |
|
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param string[] $conditions |
| 18 | 18 | * @return Predicate |
| 19 | 19 | */ |
| 20 | - public static function all (array $conditions) { |
|
| 20 | + public static function all(array $conditions) { |
|
| 21 | 21 | if (count($conditions) === 1) { |
| 22 | 22 | return reset($conditions); |
| 23 | 23 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string[] $conditions |
| 31 | 31 | * @return Predicate |
| 32 | 32 | */ |
| 33 | - public static function any (array $conditions) { |
|
| 33 | + public static function any(array $conditions) { |
|
| 34 | 34 | if (count($conditions) === 1) { |
| 35 | 35 | return reset($conditions); |
| 36 | 36 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $listOper |
| 58 | 58 | * @return Predicate |
| 59 | 59 | */ |
| 60 | - public static function compare ($a, $b, $oper = '=', $subOper = 'ANY', $listOper = 'IN') { |
|
| 60 | + public static function compare($a, $b, $oper = '=', $subOper = 'ANY', $listOper = 'IN') { |
|
| 61 | 61 | if (is_array($b)) { |
| 62 | 62 | return new static("{$a} {$listOper} (" . implode(',', $b) . ")"); |
| 63 | 63 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param string $listOper |
| 80 | 80 | * @return Predicate[] |
| 81 | 81 | */ |
| 82 | - public static function compareArray (array $values, $oper = '=', $subOper = 'ANY', $listOper = 'IN') { |
|
| 82 | + public static function compareArray(array $values, $oper = '=', $subOper = 'ANY', $listOper = 'IN') { |
|
| 83 | 83 | foreach ($values as $a => $b) { |
| 84 | 84 | $values[$a] = static::compare($a, $b, $oper, $subOper, $listOper); |
| 85 | 85 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return Predicate |
| 93 | 93 | */ |
| 94 | - public function invert () { |
|
| 94 | + public function invert() { |
|
| 95 | 95 | return new static("NOT({$this})"); |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @param DB $db |
| 15 | 15 | * @param $name |
| 16 | 16 | */ |
| 17 | - public function __construct (DB $db, $name) { |
|
| 17 | + public function __construct(DB $db, $name) { |
|
| 18 | 18 | parent::__construct($db, $name, ['entity', 'attribute', 'value']); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param string $attribute |
| 26 | 26 | * @return bool |
| 27 | 27 | */ |
| 28 | - public function exists (int $id, string $attribute): bool { |
|
| 28 | + public function exists(int $id, string $attribute): bool { |
|
| 29 | 29 | $exists = $this->cache(__FUNCTION__, function() { |
| 30 | 30 | $select = $this->select(['COUNT(*) > 0']); |
| 31 | 31 | $select->where('entity = ? AND attribute = ?'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute. |
| 44 | 44 | * @return Select |
| 45 | 45 | */ |
| 46 | - public function find (array $match) { |
|
| 46 | + public function find(array $match) { |
|
| 47 | 47 | $select = $this->select([$this['entity']]); |
| 48 | 48 | $prior = $this; |
| 49 | 49 | foreach ($match as $attribute => $value) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param int $id |
| 66 | 66 | * @return array `[attribute => value]` |
| 67 | 67 | */ |
| 68 | - public function load (int $id): array { |
|
| 68 | + public function load(int $id): array { |
|
| 69 | 69 | $load = $this->cache(__FUNCTION__, function() { |
| 70 | 70 | $select = $this->select(['attribute', 'value']); |
| 71 | 71 | $select->where('entity = ?'); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param int[] $ids |
| 82 | 82 | * @return array[] `[id => attribute => value] |
| 83 | 83 | */ |
| 84 | - public function loadAll (array $ids): array { |
|
| 84 | + public function loadAll(array $ids): array { |
|
| 85 | 85 | if (empty($ids)) { |
| 86 | 86 | return []; |
| 87 | 87 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param array $values `[attribute => value]` |
| 107 | 107 | * @return $this |
| 108 | 108 | */ |
| 109 | - public function save (int $id, array $values) { |
|
| 109 | + public function save(int $id, array $values) { |
|
| 110 | 110 | $this->delete([ |
| 111 | 111 | $this['entity']->isEqual($id), |
| 112 | 112 | $this['attribute']->isNotEqual(array_keys($values)) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $interface |
| 30 | 30 | * @return Junction |
| 31 | 31 | */ |
| 32 | - public static function fromInterface (DB $db, string $interface) { |
|
| 32 | + public static function fromInterface(DB $db, string $interface) { |
|
| 33 | 33 | try { |
| 34 | 34 | $ref = new ReflectionClass($interface); |
| 35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string $table |
| 53 | 53 | * @param Record[] $records |
| 54 | 54 | */ |
| 55 | - public function __construct (DB $db, string $table, array $records) { |
|
| 55 | + public function __construct(DB $db, string $table, array $records) { |
|
| 56 | 56 | parent::__construct($db, $table, array_keys($records)); |
| 57 | 57 | $this->records = $records; |
| 58 | 58 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param array $match |
| 67 | 67 | * @return Select |
| 68 | 68 | */ |
| 69 | - public function getCollection (string $key, array $match = []) { |
|
| 69 | + public function getCollection(string $key, array $match = []) { |
|
| 70 | 70 | $record = $this->records[$key]; |
| 71 | 71 | $select = $record->select(); |
| 72 | 72 | $select->join($this, $this[$key]->isEqual($record['id'])); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param int[] $ids Keyed by column. |
| 83 | 83 | * @return int Rows affected. |
| 84 | 84 | */ |
| 85 | - public function link (array $ids): int { |
|
| 85 | + public function link(array $ids): int { |
|
| 86 | 86 | $link = $this->cache(__FUNCTION__, function() { |
| 87 | 87 | $columns = implode(',', array_keys($this->columns)); |
| 88 | 88 | $slots = implode(',', SQL::slots(array_keys($this->columns))); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return Numeric |
| 21 | 21 | */ |
| 22 | - public function abs () { |
|
| 22 | + public function abs() { |
|
| 23 | 23 | return new Numeric($this->db, "ABS({$this})"); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param number|ExpressionInterface $arg |
| 30 | 30 | * @return Numeric |
| 31 | 31 | */ |
| 32 | - public function add ($arg) { |
|
| 32 | + public function add($arg) { |
|
| 33 | 33 | return new Numeric($this->db, "({$this} + {$arg})"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return Numeric |
| 40 | 40 | */ |
| 41 | - public function ceil () { |
|
| 41 | + public function ceil() { |
|
| 42 | 42 | return new Numeric($this->db, "CEIL({$this})"); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param number|ExpressionInterface $arg |
| 49 | 49 | * @return Numeric |
| 50 | 50 | */ |
| 51 | - public function divide ($arg) { |
|
| 51 | + public function divide($arg) { |
|
| 52 | 52 | return new Numeric($this->db, "({$this} / {$arg})"); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return Numeric |
| 59 | 59 | */ |
| 60 | - public function floor () { |
|
| 60 | + public function floor() { |
|
| 61 | 61 | return new Numeric($this->db, "FLOOR({$this})"); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return Predicate |
| 68 | 68 | */ |
| 69 | - public function isEven () { |
|
| 69 | + public function isEven() { |
|
| 70 | 70 | return new Predicate("({$this} % 2) = 0"); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return Predicate |
| 77 | 77 | */ |
| 78 | - public function isNegative () { |
|
| 78 | + public function isNegative() { |
|
| 79 | 79 | return new Predicate("{$this} < 0"); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return Predicate |
| 86 | 86 | */ |
| 87 | - public function isOdd () { |
|
| 87 | + public function isOdd() { |
|
| 88 | 88 | return new Predicate("({$this} % 2) <> 0"); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return Predicate |
| 95 | 95 | */ |
| 96 | - public function isPositive () { |
|
| 96 | + public function isPositive() { |
|
| 97 | 97 | return new Predicate("{$this} > 0"); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param number|ExpressionInterface $arg |
| 104 | 104 | * @return Numeric |
| 105 | 105 | */ |
| 106 | - public function modulo ($arg) { |
|
| 106 | + public function modulo($arg) { |
|
| 107 | 107 | return new Numeric($this->db, "({$this} % {$arg})"); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param number|ExpressionInterface $arg |
| 114 | 114 | * @return Numeric |
| 115 | 115 | */ |
| 116 | - public function multiply ($arg) { |
|
| 116 | + public function multiply($arg) { |
|
| 117 | 117 | return new Numeric($this->db, "({$this} * {$arg})"); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param number|ExpressionInterface $exponent |
| 124 | 124 | * @return Numeric |
| 125 | 125 | */ |
| 126 | - public function pow ($exponent) { |
|
| 126 | + public function pow($exponent) { |
|
| 127 | 127 | return new Numeric($this->db, "POW({$this},{$exponent})"); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param int $decimals |
| 134 | 134 | * @return Numeric |
| 135 | 135 | */ |
| 136 | - public function round (int $decimals = 0) { |
|
| 136 | + public function round(int $decimals = 0) { |
|
| 137 | 137 | return new Numeric($this->db, "ROUND({$this},{$decimals})"); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param number|ExpressionInterface $arg |
| 144 | 144 | * @return Numeric |
| 145 | 145 | */ |
| 146 | - public function subtract ($arg) { |
|
| 146 | + public function subtract($arg) { |
|
| 147 | 147 | return new Numeric($this->db, "({$this} - {$arg})"); |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $name |
| 40 | 40 | * @param string[] $columns |
| 41 | 41 | */ |
| 42 | - public function __construct (DB $db, $name, array $columns) { |
|
| 42 | + public function __construct(DB $db, $name, array $columns) { |
|
| 43 | 43 | parent::__construct($db); |
| 44 | 44 | $this->name = $name; |
| 45 | 45 | foreach ($columns as $column) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - final public function __toString () { |
|
| 55 | + final public function __toString() { |
|
| 56 | 56 | return $this->name; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param array $values |
| 63 | 63 | * @return int Rows affected. |
| 64 | 64 | */ |
| 65 | - public function apply (array $values): int { |
|
| 65 | + public function apply(array $values): int { |
|
| 66 | 66 | $columns = implode(',', array_keys($values)); |
| 67 | 67 | $values = implode(', ', $this->db->quoteArray($values)); |
| 68 | 68 | if ($this->db->getDriver() === 'sqlite') { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param Closure $prepare `():Statement` |
| 79 | 79 | * @return Statement |
| 80 | 80 | */ |
| 81 | - protected function cache (string $key, Closure $prepare) { |
|
| 81 | + protected function cache(string $key, Closure $prepare) { |
|
| 82 | 82 | return $this->_cache[$key] ?? $this->_cache[$key] = $prepare->__invoke(); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param array $match |
| 87 | 87 | * @return int |
| 88 | 88 | */ |
| 89 | - public function count (array $match = []) { |
|
| 89 | + public function count(array $match = []) { |
|
| 90 | 90 | $select = $this->select(['COUNT(*)']); |
| 91 | 91 | foreach ($this->db->matchArray($match) as $condition) { |
| 92 | 92 | $select->where($condition); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param array $match |
| 103 | 103 | * @return int Rows affected. |
| 104 | 104 | */ |
| 105 | - public function delete (array $match): int { |
|
| 105 | + public function delete(array $match): int { |
|
| 106 | 106 | $match = Predicate::all($this->db->matchArray($match)); |
| 107 | 107 | return $this->db->exec("DELETE FROM {$this} WHERE {$match}"); |
| 108 | 108 | } |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * @return Column[] |
| 112 | 112 | */ |
| 113 | - final public function getColumns (): array { |
|
| 113 | + final public function getColumns(): array { |
|
| 114 | 114 | return $this->columns; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @return string |
| 119 | 119 | */ |
| 120 | - final public function getName (): string { |
|
| 120 | + final public function getName(): string { |
|
| 121 | 121 | return $this->name; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param array $values |
| 128 | 128 | * @return Statement |
| 129 | 129 | */ |
| 130 | - public function insert (array $values) { |
|
| 130 | + public function insert(array $values) { |
|
| 131 | 131 | $columns = implode(',', array_keys($values)); |
| 132 | 132 | $values = implode(', ', $this->db->quoteArray($values)); |
| 133 | 133 | return $this->db->query("INSERT INTO {$this} ($columns) VALUES ($values)"); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $name |
| 138 | 138 | * @return bool |
| 139 | 139 | */ |
| 140 | - public function offsetExists ($name): bool { |
|
| 140 | + public function offsetExists($name): bool { |
|
| 141 | 141 | return isset($this->columns[$name]); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $name |
| 146 | 146 | * @return Column |
| 147 | 147 | */ |
| 148 | - public function offsetGet ($name) { |
|
| 148 | + public function offsetGet($name) { |
|
| 149 | 149 | return $this->columns[$name]; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param string[] $columns Defaults to all columns. |
| 156 | 156 | * @return Select |
| 157 | 157 | */ |
| 158 | - public function select (array $columns = []) { |
|
| 158 | + public function select(array $columns = []) { |
|
| 159 | 159 | if (!$columns) { |
| 160 | 160 | $columns = array_values($this->columns); |
| 161 | 161 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param string $name |
| 169 | 169 | * @return Table |
| 170 | 170 | */ |
| 171 | - public function setName (string $name) { |
|
| 171 | + public function setName(string $name) { |
|
| 172 | 172 | $clone = clone $this; |
| 173 | 173 | $clone->name = $name; |
| 174 | 174 | foreach ($this->columns as $name => $column) { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param array $match |
| 187 | 187 | * @return int Rows affected. |
| 188 | 188 | */ |
| 189 | - public function update (array $values, array $match): int { |
|
| 189 | + public function update(array $values, array $match): int { |
|
| 190 | 190 | $values = implode(', ', $this->db->matchArray($values)); |
| 191 | 191 | $match = Predicate::all($this->db->matchArray($match)); |
| 192 | 192 | return $this->db->exec("UPDATE {$this} SET {$values} WHERE {$match}"); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param string|Select $table |
| 74 | 74 | * @param string[] $columns |
| 75 | 75 | */ |
| 76 | - public function __construct (DB $db, $table, array $columns) { |
|
| 76 | + public function __construct(DB $db, $table, array $columns) { |
|
| 77 | 77 | parent::__construct($db); |
| 78 | 78 | if ($table instanceof Select) { |
| 79 | 79 | $table = $table->toSubquery(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * Gives the clone a new alias. |
| 97 | 97 | */ |
| 98 | - public function __clone () { |
|
| 98 | + public function __clone() { |
|
| 99 | 99 | $this->alias = uniqid('_') . "__{$this->table}"; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param array $args |
| 104 | 104 | * @return Statement |
| 105 | 105 | */ |
| 106 | - public function __invoke (array $args = []) { |
|
| 106 | + public function __invoke(array $args = []) { |
|
| 107 | 107 | return $this->execute($args); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - final public function __toString () { |
|
| 115 | + final public function __toString() { |
|
| 116 | 116 | return $this->alias; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param array $args Execution arguments. |
| 123 | 123 | * @return int |
| 124 | 124 | */ |
| 125 | - public function count (array $args = []): int { |
|
| 125 | + public function count(array $args = []): int { |
|
| 126 | 126 | $clone = clone $this; |
| 127 | 127 | $clone->_columns = 'COUNT(*)'; |
| 128 | 128 | return (int)$clone->execute($args)->fetchColumn(); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param array $args |
| 135 | 135 | * @return Statement |
| 136 | 136 | */ |
| 137 | - public function execute (array $args = []) { |
|
| 137 | + public function execute(array $args = []) { |
|
| 138 | 138 | if (empty($args)) { |
| 139 | 139 | return $this->db->query($this->toSql()); |
| 140 | 140 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param array $args Execution arguments. |
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | - public function fetchAll (array $args = []): array { |
|
| 152 | + public function fetchAll(array $args = []): array { |
|
| 153 | 153 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param array $args Execution arguments. |
| 163 | 163 | * @return Generator |
| 164 | 164 | */ |
| 165 | - public function fetchEach (array $args = []) { |
|
| 165 | + public function fetchEach(array $args = []) { |
|
| 166 | 166 | yield from $this->fetcher->__invoke($this->execute($args)); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @return Generator |
| 175 | 175 | */ |
| 176 | - public function getIterator () { |
|
| 176 | + public function getIterator() { |
|
| 177 | 177 | yield from $this->fetchEach(); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param string $column |
| 184 | 184 | * @return $this |
| 185 | 185 | */ |
| 186 | - public function group (string $column) { |
|
| 186 | + public function group(string $column) { |
|
| 187 | 187 | if (!strlen($this->_group)) { |
| 188 | 188 | $this->_group = " GROUP BY {$column}"; |
| 189 | 189 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $condition |
| 200 | 200 | * @return $this |
| 201 | 201 | */ |
| 202 | - public function having (string $condition) { |
|
| 202 | + public function having(string $condition) { |
|
| 203 | 203 | if (!strlen($this->_having)) { |
| 204 | 204 | $this->_having = " HAVING {$condition}"; |
| 205 | 205 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param string $type |
| 218 | 218 | * @return $this |
| 219 | 219 | */ |
| 220 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
| 220 | + public function join($table, string $condition, string $type = 'INNER') { |
|
| 221 | 221 | if ($table instanceof Select) { |
| 222 | 222 | $table = $table->toSubquery(); |
| 223 | 223 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @param int $offset |
| 233 | 233 | * @return $this |
| 234 | 234 | */ |
| 235 | - public function limit (int $limit, int $offset = 0) { |
|
| 235 | + public function limit(int $limit, int $offset = 0) { |
|
| 236 | 236 | if ($limit == 0) { |
| 237 | 237 | $this->_limit = ''; |
| 238 | 238 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param string $name Name or alias if used. |
| 252 | 252 | * @return bool |
| 253 | 253 | */ |
| 254 | - public function offsetExists ($name): bool { |
|
| 254 | + public function offsetExists($name): bool { |
|
| 255 | 255 | return true; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param string $name Name, or alias if used. |
| 262 | 262 | * @return Column |
| 263 | 263 | */ |
| 264 | - public function offsetGet ($name) { |
|
| 264 | + public function offsetGet($name) { |
|
| 265 | 265 | return new Column($this->db, $name, $this->alias); |
| 266 | 266 | } |
| 267 | 267 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param string $order |
| 272 | 272 | * @return $this |
| 273 | 273 | */ |
| 274 | - public function order (string $order) { |
|
| 274 | + public function order(string $order) { |
|
| 275 | 275 | if (strlen($order)) { |
| 276 | 276 | $order = " ORDER BY {$order}"; |
| 277 | 277 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | /** |
| 283 | 283 | * @return Statement |
| 284 | 284 | */ |
| 285 | - public function prepare () { |
|
| 285 | + public function prepare() { |
|
| 286 | 286 | return $this->db->prepare($this->toSql()); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param Closure $fetcher |
| 291 | 291 | * @return $this |
| 292 | 292 | */ |
| 293 | - public function setFetcher (Closure $fetcher) { |
|
| 293 | + public function setFetcher(Closure $fetcher) { |
|
| 294 | 294 | $this->fetcher = $fetcher; |
| 295 | 295 | return $this; |
| 296 | 296 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - public function toSql (): string { |
|
| 301 | + public function toSql(): string { |
|
| 302 | 302 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
| 303 | 303 | $sql .= $this->_join; |
| 304 | 304 | $sql .= $this->_where; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return string |
| 316 | 316 | */ |
| 317 | - public function toSubquery (): string { |
|
| 317 | + public function toSubquery(): string { |
|
| 318 | 318 | return "({$this->toSql()}) AS {$this->alias}"; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param string $condition |
| 325 | 325 | * @return $this |
| 326 | 326 | */ |
| 327 | - public function where (string $condition) { |
|
| 327 | + public function where(string $condition) { |
|
| 328 | 328 | if (!strlen($this->_where)) { |
| 329 | 329 | $this->_where = " WHERE {$condition}"; |
| 330 | 330 | } |