Id   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromResourceId() 0 3 1
A getId() 0 3 1
A __construct() 0 7 1
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