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

SanitizesNumbers::sanitize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
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