Passed
Push — main ( 7e82e7...91ee3f )
by Michael
03:29
created

SanitizesNumbers   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 12
ccs 4
cts 4
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A sanitize() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\ValueObjects\Concerns;
6
7
trait SanitizesNumbers
8
{
9
    /**
10
     * @param  int|float|string|null  $number
11
     *
12
     * @return string
13
     */
14 23
    public function sanitize(int|float|string|null $number): string
15
    {
16 23
        return str($number ?? '0')
17 23
            ->replace(',', '.')
18 23
            ->value();
19
    }
20
}
21