Id   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromInteger() 0 4 1
A __toString() 0 4 1
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
    /**
33
     * @return string
34
     */
35
    public function __toString()
36
    {
37
        return (string) $this->id;
38
    }
39
}
40