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

StrCastTrait::toStr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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