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

Integer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A value() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\ValueObjects\Collection\Primitive;
6
7
use MichaelRubel\ValueObjects\Concerns\SanitizesNumbers;
8
use MichaelRubel\ValueObjects\ValueObject;
9
use PHP\Math\BigNumber\BigNumber;
10
11
/**
12
 * @method static static make(int|float|string|null $number)
13
 */
14
class Integer extends ValueObject
15
{
16
    use SanitizesNumbers;
17
18
    /**
19
     * @var BigNumber
20
     */
21
    protected BigNumber $number;
22
23
    /**
24
     * Create a new instance of the value object.
25
     *
26
     * @param  int|float|string|null  $number
27
     */
28 11
    public function __construct(int|float|string|null $number)
29
    {
30 11
        $this->number = new BigNumber($this->sanitize($number), 0);
31
    }
32
33
    /**
34
     * Get the object value.
35
     *
36
     * @return int
37
     */
38 10
    public function value(): int
39
    {
40 10
        return (int) $this->number->getValue();
41
    }
42
}
43