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

NumCastFloatTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toFloat() 0 6 2
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 a float.
10
 */
11
trait NumCastFloatTrait
12
{
13
14
    use AbstractTrait;
15
16
    /**
17
     * Casts the expression as a floating point number.
18
     *
19
     * @return Num
20
     */
21
    public function toFloat()
22
    {
23
        if ($this->db->isSQLite()) {
24
            return Num::factory($this->db, "CAST({$this} AS REAL)");
25
        }
26
        return Num::factory($this->db, "({$this} + 0)");
27
    }
28
}
29