Completed
Pull Request — master (#4)
by Woody
02:12
created

Identifier::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Equip\ValueObject;
4
5
use function Assert\that;
6
7
class Identifier
8
{
9
    /**
10
     * @var int|null
11
     */
12
    private $id;
13
14
    /**
15
     * @param int|null $id
16
     * @param boolean $is_required
17
     */
18 10
    public function __construct($id, $is_required = true)
19
    {
20 10
        $assert = that($id);
21
22 10
        if (!$is_required) {
23 1
            $assert->nullOr();
24 1
        }
25
26 10
        $assert->integer()->greaterThan(0);
27
28 3
        $this->id = $id;
29 3
    }
30
31
    /**
32
     * @return int|null
33
     */
34 3
    public function value()
35
    {
36 3
        return $this->id;
37
    }
38
}
39