Passed
Push — master ( 6db175...709bfd )
by y
01:41
created

StrCastTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A toStr() 0 6 1
1
<?php
2
3
namespace Helix\DB\Fluent\Str;
4
5
use Helix\DB\Fluent\AbstractTrait;
6
use Helix\DB\Fluent\Str;
7
8
/**
9
 * Further manipulate the expression as a character string.
10
 */
11
trait StrCastTrait
12
{
13
14
    use AbstractTrait;
15
16
    /**
17
     * Casts the expression as a character string.
18
     *
19
     * @return Str
20
     */
21
    public function toStr()
22
    {
23
        return Str::fromFormat($this->db, [
24
            'mysql' => "CAST(%s AS CHAR)",
25
            'sqlite' => "CAST(%s AS TEXT)"
26
        ], $this);
27
    }
28
}
29