Project::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ValueObject;
4
5
class Project
6
{
7
8
    /** @var int */
9
    private $id;
10
11
    /** @var string */
12
    private $name;
13
14
    /** @var bool */
15
    private $isMergeRequestsEnabled;
16
17
    /**
18
     * Project constructor.
19
     * @param int $id
20
     * @param string $name
21
     * @param bool $isMergeRequestsEnabled
22
     */
23
    public function __construct(int $id, string $name, bool $isMergeRequestsEnabled)
24
    {
25
        $this->id = $id;
26
        $this->name = $name;
27
        $this->isMergeRequestsEnabled = $isMergeRequestsEnabled;
28
    }
29
30
    /**
31
     * @param array $project
32
     * @return Project
33
     */
34
    public static function fromArray(array $project): self
35
    {
36
        return new self(
37
            (int)$project['id'],
38
            (string)$project['name'],
39
            (bool)$project['merge_requests_enabled']
40
        );
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getId(): int
47
    {
48
        return $this->id;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName(): string
55
    {
56
        return $this->name;
57
    }
58
59
    /**
60
     * @return bool
61
     */
62
    public function isMergeRequestsEnabled(): bool
63
    {
64
        return $this->isMergeRequestsEnabled;
65
    }
66
}
67