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

Integer::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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