| Total Complexity | 7 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait CastTrait { |
||
| 6 | |||
| 7 | use AbstractTrait; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * `COALESCE($this, ...$values)` |
||
| 11 | * |
||
| 12 | * @param scalar[] $values |
||
| 13 | * @return Value |
||
| 14 | */ |
||
| 15 | public function coalesce (array $values) { |
||
| 16 | array_unshift($values, $this); |
||
| 17 | $values = $this->db->quoteList($values); |
||
| 18 | return Value::factory($this->db, "COALESCE({$values})"); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Casts the expression to a floating point number. |
||
| 23 | * |
||
| 24 | * @return Num |
||
| 25 | */ |
||
| 26 | public function toFloat () { |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Casts the expression to a signed integer. |
||
| 35 | * |
||
| 36 | * @return Num |
||
| 37 | */ |
||
| 38 | public function toInt () { |
||
| 39 | if ($this->db->isSQLite()) { |
||
| 40 | return Num::factory($this->db, "CAST({$this} AS INTEGER)"); |
||
| 41 | } |
||
| 42 | return Num::factory($this->db, "CAST({$this} AS SIGNED)"); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Casts the expression to a character string. |
||
| 47 | * |
||
| 48 | * @return Text |
||
| 49 | */ |
||
| 50 | public function toText () { |
||
| 55 | } |
||
| 56 | } |