Passed
Push — master ( 221c35...fdb910 )
by Petr
02:59
created

Integers   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 20
c 0
b 0
f 0
ccs 16
cts 16
cp 1
rs 10

1 Method

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