Passed
Push — master ( 222f48...0fa176 )
by y
01:47
created

TextCastTrait::toText()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Helix\DB\Fluent\Text;
4
5
use Helix\DB\Fluent\AbstractTrait;
6
use Helix\DB\Fluent\Text;
7
8
trait TextCastTrait {
9
10
    use AbstractTrait;
11
12
    /**
13
     * Casts the expression to a character string.
14
     *
15
     * @return Text
16
     */
17
    public function toText () {
18
        if ($this->db->isSQLite()) {
19
            return Text::factory($this->db, "CAST({$this} AS TEXT)");
20
        }
21
        return Text::factory($this->db, "CAST({$this} AS CHAR)");
22
    }
23
}
24