NumCastFloatTrait::toFloat()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
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 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
        return Num::fromFormat($this->db, [
24
            'mysql' => "(%s + 0)",
25
            'sqlite' => "CAST(%s AS REAL)"
26
        ], $this);
27
    }
28
}
29