NumCastFloatTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toFloat() 0 6 1
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