@@ -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|ValueInterface $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|ValueInterface $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|ValueInterface $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|ValueInterface $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|ValueInterface $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|ValueInterface $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 |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string $subject |
| 53 | 53 | * @param array $values `[when => then]` for the subject. |
| 54 | 54 | */ |
| 55 | - public function __construct (DB $db, string $subject = null, array $values = []) { |
|
| 55 | + public function __construct(DB $db, string $subject = null, array $values = []) { |
|
| 56 | 56 | parent::__construct($db, ''); |
| 57 | 57 | $this->subject = $subject; |
| 58 | 58 | $this->setValues($values); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * @return string |
| 63 | 63 | */ |
| 64 | - public function __toString () { |
|
| 64 | + public function __toString() { |
|
| 65 | 65 | $sql = 'CASE'; |
| 66 | 66 | if (isset($this->subject)) { |
| 67 | 67 | $sql .= " {$this->subject}"; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param string|ValueInterface $else |
| 81 | 81 | * @return $this |
| 82 | 82 | */ |
| 83 | - public function setElse ($else) { |
|
| 83 | + public function setElse($else) { |
|
| 84 | 84 | $this->else = isset($else) ? $this->db->quote($else) : null; |
| 85 | 85 | return $this; |
| 86 | 86 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string|ValueInterface $then |
| 93 | 93 | * @return $this |
| 94 | 94 | */ |
| 95 | - public function setValue ($when, $then) { |
|
| 95 | + public function setValue($when, $then) { |
|
| 96 | 96 | $this->values[$this->db->quote($when)] = $this->db->quote($then); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param array $values `[when => then]` |
| 104 | 104 | * @return $this |
| 105 | 105 | */ |
| 106 | - public function setValues (array $values) { |
|
| 106 | + public function setValues(array $values) { |
|
| 107 | 107 | foreach ($values as $when => $then) { |
| 108 | 108 | $this->setValue($when, $then); |
| 109 | 109 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return Text |
| 21 | 21 | */ |
| 22 | - public function getDate () { |
|
| 22 | + public function getDate() { |
|
| 23 | 23 | return new Text($this->db, $this->getDateTimeFormat('%Y-%m-%d')); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string|array $format Format, or formats keyed by driver name. |
| 30 | 30 | * @return Text |
| 31 | 31 | */ |
| 32 | - public function getDateTimeFormat ($format) { |
|
| 32 | + public function getDateTimeFormat($format) { |
|
| 33 | 33 | $driver = $this->db->getDriver(); |
| 34 | 34 | if (is_array($format)) { |
| 35 | 35 | $format = $format[$driver]; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return Numeric |
| 50 | 50 | */ |
| 51 | - public function getDay () { |
|
| 51 | + public function getDay() { |
|
| 52 | 52 | return new Numeric($this->db, $this->getDateTimeFormat('%d')); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return Numeric |
| 59 | 59 | */ |
| 60 | - public function getDayOfWeek () { |
|
| 60 | + public function getDayOfWeek() { |
|
| 61 | 61 | return new Numeric($this->db, $this->getDateTimeFormat('%w')); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return Numeric |
| 68 | 68 | */ |
| 69 | - public function getDayOfYear () { |
|
| 69 | + public function getDayOfYear() { |
|
| 70 | 70 | return new Numeric($this->db, $this->getDateTimeFormat('%j')); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return Numeric |
| 77 | 77 | */ |
| 78 | - public function getHours () { |
|
| 78 | + public function getHours() { |
|
| 79 | 79 | return new Numeric($this->db, $this->getDateTimeFormat('%H')); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return Numeric |
| 86 | 86 | */ |
| 87 | - public function getMinutes () { |
|
| 87 | + public function getMinutes() { |
|
| 88 | 88 | return new Numeric($this->db, $this->getDateTimeFormat([ |
| 89 | 89 | 'mysql' => '%i', |
| 90 | 90 | 'sqlite' => '%M' |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return Numeric |
| 98 | 98 | */ |
| 99 | - public function getMonth () { |
|
| 99 | + public function getMonth() { |
|
| 100 | 100 | return new Numeric($this->db, $this->getDateTimeFormat('%m')); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return Numeric |
| 107 | 107 | */ |
| 108 | - public function getSeconds () { |
|
| 108 | + public function getSeconds() { |
|
| 109 | 109 | return new Numeric($this->db, $this->getDateTimeFormat('%S')); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return Text |
| 116 | 116 | */ |
| 117 | - public function getTime () { |
|
| 117 | + public function getTime() { |
|
| 118 | 118 | return new Text($this->db, $this->getDateTimeFormat([ |
| 119 | 119 | 'mysql' => '%H:%i:%S', |
| 120 | 120 | 'sqlite' => '%H:%M:%S' |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return Numeric |
| 128 | 128 | */ |
| 129 | - public function getTimestamp () { |
|
| 129 | + public function getTimestamp() { |
|
| 130 | 130 | switch ($this->db) { |
| 131 | 131 | case 'sqlite': |
| 132 | 132 | return new Numeric($this->db, "STRFTIME('%s',{$this})"); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return Numeric |
| 142 | 142 | */ |
| 143 | - public function getWeekOfYear () { |
|
| 143 | + public function getWeekOfYear() { |
|
| 144 | 144 | return new Numeric($this->db, $this->getDateTimeFormat([ |
| 145 | 145 | 'mysql' => '%U', |
| 146 | 146 | 'sqlite' => '%W' |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return Numeric |
| 154 | 154 | */ |
| 155 | - public function getYear () { |
|
| 155 | + public function getYear() { |
|
| 156 | 156 | return new Numeric($this->db, $this->getDateTimeFormat('%Y')); |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return Numeric |
| 16 | 16 | */ |
| 17 | - public function toFloat () { |
|
| 17 | + public function toFloat() { |
|
| 18 | 18 | switch ($this->db) { |
| 19 | 19 | case 'sqlite': |
| 20 | 20 | return new Numeric($this->db, "CAST({$this} AS REAL)"); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return Numeric |
| 30 | 30 | */ |
| 31 | - public function toInt () { |
|
| 31 | + public function toInt() { |
|
| 32 | 32 | switch ($this->db) { |
| 33 | 33 | case 'sqlite': |
| 34 | 34 | return new Numeric($this->db, "CAST({$this} AS INTEGER)"); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @return Text |
| 19 | 19 | */ |
| 20 | - public function getHex () { |
|
| 20 | + public function getHex() { |
|
| 21 | 21 | return new Text($this->db, "HEX({$this})"); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return Numeric |
| 30 | 30 | */ |
| 31 | - public function getLength () { |
|
| 31 | + public function getLength() { |
|
| 32 | 32 | switch ($this->db) { |
| 33 | 33 | case 'sqlite': |
| 34 | 34 | return new Numeric($this->db, "LENGTH(CAST({$this} AS TEXT))"); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return Text |
| 44 | 44 | */ |
| 45 | - public function getLower () { |
|
| 45 | + public function getLower() { |
|
| 46 | 46 | return new Text($this->db, "LOWER({$this})"); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $substring |
| 55 | 55 | * @return Numeric |
| 56 | 56 | */ |
| 57 | - public function getPosition (string $substring) { |
|
| 57 | + public function getPosition(string $substring) { |
|
| 58 | 58 | $substring = $this->db->quote($substring); |
| 59 | 59 | switch ($this->db) { |
| 60 | 60 | case 'sqlite': |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param string $replace |
| 72 | 72 | * @return Text |
| 73 | 73 | */ |
| 74 | - public function getReplacement (string $search, string $replace) { |
|
| 74 | + public function getReplacement(string $search, string $replace) { |
|
| 75 | 75 | $search = $this->db->quote($search); |
| 76 | 76 | $replace = $this->db->quote($replace); |
| 77 | 77 | return new Text($this->db, "REPLACE({$this},{$search},{$replace})"); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return Numeric |
| 84 | 84 | */ |
| 85 | - public function getSize () { |
|
| 85 | + public function getSize() { |
|
| 86 | 86 | switch ($this->db) { |
| 87 | 87 | case 'sqlite': |
| 88 | 88 | return new Numeric($this->db, "LENGTH(CAST({$this} AS BLOB))"); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param int $length |
| 99 | 99 | * @return Text |
| 100 | 100 | */ |
| 101 | - public function getSubstring (int $start, int $length = null) { |
|
| 101 | + public function getSubstring(int $start, int $length = null) { |
|
| 102 | 102 | if (isset($length)) { |
| 103 | 103 | return new Text($this->db, "SUBSTR({$this},{$start},{$length})"); |
| 104 | 104 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return Text |
| 112 | 112 | */ |
| 113 | - public function getUpper () { |
|
| 113 | + public function getUpper() { |
|
| 114 | 114 | return new Text($this->db, "UPPER({$this})"); |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | \ No newline at end of file |
@@ -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) { |
| 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 (string $aggregate = 'ALL') { |
|
| 49 | + public function getCount(string $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 (string $aggregate = 'ALL') { |
|
| 77 | + public function getSum(string $aggregate = 'ALL') { |
|
| 78 | 78 | return new Numeric($this->db, "SUM({$aggregate} {$this})"); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @return Text |
| 16 | 16 | */ |
| 17 | - public function toText () { |
|
| 17 | + public function toText() { |
|
| 18 | 18 | if ($this->db == 'sqlite') { |
| 19 | 19 | return new Text($this->db, "CAST({$this} AS TEXT)"); |
| 20 | 20 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @param array $values |
| 29 | 29 | * @return Value |
| 30 | 30 | */ |
| 31 | - public function coalesce (array $values) { |
|
| 31 | + public function coalesce(array $values) { |
|
| 32 | 32 | array_unshift($values, $this); |
| 33 | 33 | $values = $this->db->quoteList($values); |
| 34 | 34 | return new Value($this->db, "COALESCE({$values})"); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param array $values `[when => then]` |
| 41 | 41 | * @return Choice |
| 42 | 42 | */ |
| 43 | - public function getChoice (array $values) { |
|
| 43 | + public function getChoice(array $values) { |
|
| 44 | 44 | return new Choice($this->db, "{$this}", $values); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param null|bool|number|string|Select $arg |
| 54 | 54 | * @return Predicate |
| 55 | 55 | */ |
| 56 | - public function is ($arg): Predicate { |
|
| 56 | + public function is($arg): Predicate { |
|
| 57 | 57 | $driver = $this->db->getDriver(); |
| 58 | 58 | if ($arg instanceof Select) { |
| 59 | 59 | switch ($driver) { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param number|string $max |
| 82 | 82 | * @return Predicate |
| 83 | 83 | */ |
| 84 | - public function isBetween ($min, $max) { |
|
| 84 | + public function isBetween($min, $max) { |
|
| 85 | 85 | $min = $this->db->quote($min); |
| 86 | 86 | $max = $this->db->quote($max); |
| 87 | 87 | return new Predicate("{$this} BETWEEN {$min} AND {$max}"); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param bool|number|string|array|Select $arg |
| 94 | 94 | * @return Predicate |
| 95 | 95 | */ |
| 96 | - public function isEqual ($arg) { |
|
| 96 | + public function isEqual($arg) { |
|
| 97 | 97 | return $this->db->match($this, $arg); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param string $multi `ALL|ANY` |
| 110 | 110 | * @return Predicate |
| 111 | 111 | */ |
| 112 | - public function isGreater ($arg, string $multi = 'ALL') { |
|
| 112 | + public function isGreater($arg, string $multi = 'ALL') { |
|
| 113 | 113 | if ($arg instanceof Select) { |
| 114 | 114 | switch ($this->db) { |
| 115 | 115 | case 'sqlite': |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $multi `ALL|ANY` |
| 140 | 140 | * @return Predicate |
| 141 | 141 | */ |
| 142 | - public function isGreaterOrEqual ($arg, string $multi = 'ALL') { |
|
| 142 | + public function isGreaterOrEqual($arg, string $multi = 'ALL') { |
|
| 143 | 143 | if ($arg instanceof Select) { |
| 144 | 144 | switch ($this->db) { |
| 145 | 145 | case 'sqlite': |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $multi `ALL|ANY` |
| 170 | 170 | * @return Predicate |
| 171 | 171 | */ |
| 172 | - public function isLess ($arg, string $multi = 'ALL') { |
|
| 172 | + public function isLess($arg, string $multi = 'ALL') { |
|
| 173 | 173 | if ($arg instanceof Select) { |
| 174 | 174 | switch ($this->db) { |
| 175 | 175 | case 'sqlite': |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $multi `ALL|ANY` |
| 200 | 200 | * @return Predicate |
| 201 | 201 | */ |
| 202 | - public function isLessOrEqual ($arg, string $multi = 'ALL') { |
|
| 202 | + public function isLessOrEqual($arg, string $multi = 'ALL') { |
|
| 203 | 203 | if ($arg instanceof Select) { |
| 204 | 204 | switch ($this->db) { |
| 205 | 205 | case 'sqlite': |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @param string $pattern |
| 224 | 224 | * @return Predicate |
| 225 | 225 | */ |
| 226 | - public function isLike (string $pattern) { |
|
| 226 | + public function isLike(string $pattern) { |
|
| 227 | 227 | $pattern = $this->db->quote($pattern); |
| 228 | 228 | return new Predicate("{$this} LIKE {$pattern}"); |
| 229 | 229 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param null|bool|number|string|Select $arg |
| 235 | 235 | * @return Predicate |
| 236 | 236 | */ |
| 237 | - public function isNot ($arg) { |
|
| 237 | + public function isNot($arg) { |
|
| 238 | 238 | return $this->is($arg)->invert(); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param number|string $max |
| 246 | 246 | * @return Predicate |
| 247 | 247 | */ |
| 248 | - public function isNotBetween ($min, $max) { |
|
| 248 | + public function isNotBetween($min, $max) { |
|
| 249 | 249 | $min = $this->db->quote($min); |
| 250 | 250 | $max = $this->db->quote($max); |
| 251 | 251 | return new Predicate("{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @param bool|number|string|array|Select $arg |
| 258 | 258 | * @return Predicate |
| 259 | 259 | */ |
| 260 | - public function isNotEqual ($arg) { |
|
| 260 | + public function isNotEqual($arg) { |
|
| 261 | 261 | if ($arg instanceof Select) { |
| 262 | 262 | return new Predicate("{$this} NOT IN ({$arg->toSql()})"); |
| 263 | 263 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $pattern |
| 274 | 274 | * @return Predicate |
| 275 | 275 | */ |
| 276 | - public function isNotLike (string $pattern) { |
|
| 276 | + public function isNotLike(string $pattern) { |
|
| 277 | 277 | $pattern = $this->db->quote($pattern); |
| 278 | 278 | return new Predicate("{$this} NOT LIKE {$pattern}"); |
| 279 | 279 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string $pattern |
| 285 | 285 | * @return Predicate |
| 286 | 286 | */ |
| 287 | - public function isNotRegExp (string $pattern) { |
|
| 287 | + public function isNotRegExp(string $pattern) { |
|
| 288 | 288 | $pattern = $this->db->quote($pattern); |
| 289 | 289 | return new Predicate("{$this} NOT REGEXP {$pattern}"); |
| 290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param string $pattern |
| 296 | 296 | * @return Predicate |
| 297 | 297 | */ |
| 298 | - public function isRegExp (string $pattern) { |
|
| 298 | + public function isRegExp(string $pattern) { |
|
| 299 | 299 | $pattern = $this->db->quote($pattern); |
| 300 | 300 | return new Predicate("{$this} REGEXP {$pattern}"); |
| 301 | 301 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param string|EntityInterface $class |
| 60 | 60 | * @return Record |
| 61 | 61 | */ |
| 62 | - public static function fromClass (DB $db, $class) { |
|
| 62 | + public static function fromClass(DB $db, $class) { |
|
| 63 | 63 | try { |
| 64 | 64 | $rClass = new ReflectionClass($class); |
| 65 | 65 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string[] $columns Property names. |
| 93 | 93 | * @param EAV[] $eav Keyed by property name. |
| 94 | 94 | */ |
| 95 | - public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
| 95 | + public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
| 96 | 96 | parent::__construct($db, $table, $columns); |
| 97 | 97 | $this->proto = $proto; |
| 98 | 98 | try { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param array[] $eavMatch `[eav property => attribute => mixed]` |
| 129 | 129 | * @return Select |
| 130 | 130 | */ |
| 131 | - public function find (array $match, array $eavMatch = []) { |
|
| 131 | + public function find(array $match, array $eavMatch = []) { |
|
| 132 | 132 | $select = $this->select(); |
| 133 | 133 | foreach ($match as $a => $b) { |
| 134 | 134 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param Statement $statement |
| 147 | 147 | * @return EntityInterface[] Enumerated |
| 148 | 148 | */ |
| 149 | - public function getAll (Statement $statement): array { |
|
| 149 | + public function getAll(Statement $statement): array { |
|
| 150 | 150 | return iterator_to_array($this->getEach($statement)); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param Statement $statement |
| 158 | 158 | * @return Generator |
| 159 | 159 | */ |
| 160 | - public function getEach (Statement $statement) { |
|
| 160 | + public function getEach(Statement $statement) { |
|
| 161 | 161 | do { |
| 162 | 162 | $entities = []; |
| 163 | 163 | for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) { |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | * @param string $property |
| 176 | 176 | * @return EAV |
| 177 | 177 | */ |
| 178 | - final public function getEav (string $property) { |
|
| 178 | + final public function getEav(string $property) { |
|
| 179 | 179 | return $this->eav[$property]; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @return EntityInterface |
| 184 | 184 | */ |
| 185 | - public function getProto () { |
|
| 185 | + public function getProto() { |
|
| 186 | 186 | return $this->proto; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param EntityInterface $entity |
| 191 | 191 | * @return array |
| 192 | 192 | */ |
| 193 | - protected function getValues (EntityInterface $entity): array { |
|
| 193 | + protected function getValues(EntityInterface $entity): array { |
|
| 194 | 194 | $values = []; |
| 195 | 195 | foreach (array_keys($this->columns) as $name) { |
| 196 | 196 | $values[$name] = $this->properties[$name]->getValue($entity); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param int $id |
| 205 | 205 | * @return null|EntityInterface |
| 206 | 206 | */ |
| 207 | - public function load (int $id) { |
|
| 207 | + public function load(int $id) { |
|
| 208 | 208 | $load = $this->cache(__FUNCTION__, function() { |
| 209 | 209 | return $this->select(array_keys($this->columns))->where('id = ?')->prepare(); |
| 210 | 210 | }); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param EntityInterface[] $entities |
| 224 | 224 | */ |
| 225 | - protected function loadEav (array $entities): void { |
|
| 225 | + protected function loadEav(array $entities): void { |
|
| 226 | 226 | $ids = array_keys($entities); |
| 227 | 227 | foreach ($this->eav as $name => $eav) { |
| 228 | 228 | foreach ($eav->loadAll($ids) as $id => $values) { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param EntityInterface $entity |
| 240 | 240 | * @return int ID |
| 241 | 241 | */ |
| 242 | - public function save (EntityInterface $entity): int { |
|
| 242 | + public function save(EntityInterface $entity): int { |
|
| 243 | 243 | if (!$entity->getId()) { |
| 244 | 244 | $this->saveInsert($entity); |
| 245 | 245 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | /** |
| 254 | 254 | * @param EntityInterface $entity |
| 255 | 255 | */ |
| 256 | - protected function saveEav (EntityInterface $entity): void { |
|
| 256 | + protected function saveEav(EntityInterface $entity): void { |
|
| 257 | 257 | $id = $entity->getId(); |
| 258 | 258 | foreach ($this->eav as $name => $eav) { |
| 259 | 259 | $values = $this->properties[$name]->getValue($entity); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @param EntityInterface $entity |
| 270 | 270 | */ |
| 271 | - protected function saveInsert (EntityInterface $entity): void { |
|
| 271 | + protected function saveInsert(EntityInterface $entity): void { |
|
| 272 | 272 | $insert = $this->cache(__FUNCTION__, function() { |
| 273 | 273 | $slots = SQL::slots(array_keys($this->columns)); |
| 274 | 274 | unset($slots['id']); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param EntityInterface $entity |
| 288 | 288 | */ |
| 289 | - protected function saveUpdate (EntityInterface $entity): void { |
|
| 289 | + protected function saveUpdate(EntityInterface $entity): void { |
|
| 290 | 290 | $this->cache(__FUNCTION__, function() { |
| 291 | 291 | $slots = SQL::slotsEqual(array_keys($this->columns)); |
| 292 | 292 | unset($slots['id']); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param array $columns Defaults to all columns. |
| 302 | 302 | * @return Select |
| 303 | 303 | */ |
| 304 | - public function select (array $columns = []) { |
|
| 304 | + public function select(array $columns = []) { |
|
| 305 | 305 | $select = parent::select($columns); |
| 306 | 306 | if (empty($columns)) { |
| 307 | 307 | $select->setFetcher(function(Statement $statement) { |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param EntityInterface $proto |
| 316 | 316 | * @return $this |
| 317 | 317 | */ |
| 318 | - public function setProto (EntityInterface $proto) { |
|
| 318 | + public function setProto(EntityInterface $proto) { |
|
| 319 | 319 | $this->proto = $proto; |
| 320 | 320 | return $this; |
| 321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param EntityInterface $entity |
| 325 | 325 | * @param array $values |
| 326 | 326 | */ |
| 327 | - protected function setValues (EntityInterface $entity, array $values): void { |
|
| 327 | + protected function setValues(EntityInterface $entity, array $values): void { |
|
| 328 | 328 | foreach ($values as $name => $value) { |
| 329 | 329 | settype($value, $this->types[$name]); |
| 330 | 330 | $this->properties[$name]->setValue($entity, $value); |