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

TextCastTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 14
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toText() 0 5 2
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