Id::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Dolibarr\Client\Domain\Common;
5
6
use Dolibarr\Client\Domain\Resource\ResourceId;
7
use Webmozart\Assert\Assert;
8
9
trait Id
10
{
11
    /**
12
     * @var int
13
     */
14
    private $id;
15
16
    /**
17
     * @param int $id
18
     */
19
    public function __construct($id)
20
    {
21
        Assert::integer($id);
22
        Assert::greaterThan($id, 0);
23
        Assert::notNull($id);
24
25
        $this->id = $id;
26
    }
27
28
    /**
29
     * @param ResourceId $resourceId
30
     *
31
     * @return self
32
     */
33
    public static function fromResourceId(ResourceId $resourceId)
34
    {
35
        return new self($resourceId->getId());
36
    }
37
38
    /**
39
     * @return int
40
     */
41
    public function getId()
42
    {
43
        return $this->id;
44
    }
45
}
46