Test Failed
Pull Request — master (#20)
by Dennis
02:14
created

Id::id()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
namespace Link0\Bunq\Domain;
4
5
use Assert\Assertion;
6
7
final class Id
8
{
9
    /**
10
     * @var int
11
     */
12
    private $id;
13
14
    /**
15
     * @param int $id
16
     */
17
    private function __construct(int $id)
18
    {
19
        Assertion::greaterOrEqualThan($id, 0, 'Id must be greater or equal to 0');
20
        $this->id = $id;
21
    }
22
23
    /**
24
     * @param int $id
25
     * @return Id
26
     */
27
    public static function fromInteger(int $id): Id
28
    {
29
        return new Id($id);
30
    }
31
32
    public function id()
33
    {
34
        return $this->id;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function __toString()
41
    {
42
        return (string) $this->id();
43
    }
44
}
45