Double   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filterSingle() 0 12 3
1
<?php
2
declare(strict_types=1);
3
namespace Sirius\Filtration\Filter;
4
5
class Double extends AbstractFilter
6
{
7
    const OPTION_PRECISION = 'precision';
8
9
    protected $options = [
10
        self::OPTION_PRECISION => 2
11
    ];
12
13 3
    public function filterSingle($value, string $valueIdentifier = null)
14
    {
15 3
        if (is_object($value)) {
16 1
            return $value;
17
        }
18 2
        if ($value == 0) {
19 1
            return 0;
20
        }
21 1
        $value = floatval($value);
22 1
        $multiplier = pow(10, (int) $this->options['precision']);
23 1
        return round($value * $multiplier) / $multiplier;
24
    }
25
}
26