Passed
Pull Request — master (#16)
by steven
04:56
created

PositiveNumber::equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Company\ValueObjects;
4
5
class PositiveNumber
6
{
7
8
    /**
9
     * @var int
10
     */
11
    private $value;
12
13
    /**
14
     * @param int $value
15
     */
16
    public function __construct(int $value)
17
    {
18
        if ($value < 1) {
19
            throw new \InvalidArgumentException(
20
                'Value has to be greater than 0, '.$value.' given.'
21
            );
22
        }
23
        $this->value = $value;
24
    }
25
26
    /**
27
     * @return int
28
     */
29
    public function toNative(): int
30
    {
31
        return $this->value;
32
    }
33
34
    /**
35
     * @param PositiveNumber $positiveNumber
36
     * @return bool
37
     */
38
    public function equals(PositiveNumber $positiveNumber): bool
39
    {
40
        return $this->toNative() === $positiveNumber->toNative();
41
    }
42
}
43