Numbers   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 17
c 0
b 0
f 0
dl 0
loc 23
ccs 19
cts 19
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 21 3
1
<?php
2
3
namespace Riesenia\Pohoda\Common\OptionsResolver\Normalizers;
4
5
class Numbers extends AbstractNormalizer
6
{
7 50
    public function normalize(mixed $options, mixed $value): string
8
    {
9 50
        $preform = \strval(
10 50
            \preg_replace(
11 50
                '/[^0-9,.-]/',
12 50
                '',
13 50
                \strval($value),
14 50
            ),
15 50
        );
16 50
        if ($this->nullable && empty(\strlen($preform))) {
17 1
            return '';
18
        }
19 50
        return \str_replace(
20 50
            ',',
21 50
            '.',
22 50
            \strval(
23 50
                \floatval(
24 50
                    \str_replace(
25 50
                        ',',
26 50
                        '.',
27 50
                        $preform,
28 50
                    ),
29 50
                ),
30 50
            ),
31 50
        );
32
    }
33
}
34