Passed
Push — master ( cf86c2...f16abf )
by y
02:43
created

NumCastIntTrait::toInt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Helix\DB\Fluent\Num;
4
5
use Helix\DB\Fluent\AbstractTrait;
6
use Helix\DB\Fluent\Num;
7
8
/**
9
 * Further manipulate the expression as an integer.
10
 */
11
trait NumCastIntTrait
12
{
13
14
    use AbstractTrait;
15
16
    /**
17
     * Casts the expression as a signed integer.
18
     *
19
     * @return Num
20
     */
21
    public function toInt()
22
    {
23
        if ($this->db->isSQLite()) {
24
            return Num::factory($this->db, "CAST({$this} AS INTEGER)");
25
        }
26
        return Num::factory($this->db, "CAST({$this} AS SIGNED)");
27
    }
28
}
29