Passed
Push — master ( e8c85a...007af2 )
by Daniel
02:09
created

User::getWebUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ValueObject;
4
5
class User
6
{
7
    public const STATE_ACTIVE = 'active';
8
    public const STATE_BLOCKED = 'blocked';
9
10
    /** @var int */
11
    private $id;
12
13
    /** @var string */
14
    private $username;
15
16
    /** @var string */
17
    private $name;
18
19
    /** @var string */
20
    private $webUrl;
21
22
    /**
23
     * Project constructor.
24
     * @param int $id
25
     * @param string $username
26
     * @param string $name
27
     * @param string $webUrl
28
     */
29 44
    public function __construct(
30
        int $id,
31
        string $username,
32
        string $name,
33
        string $webUrl
34
    ) {
35 44
        $this->id = $id;
36 44
        $this->username = $username;
37 44
        $this->name = $name;
38 44
        $this->webUrl = $webUrl;
39 44
    }
40
41
    /**
42
     * @param array $user
43
     * @return User
44
     */
45 44
    public static function fromArray(array $user): self
46
    {
47 44
        return new self(
48 44
            (int)$user['id'],
49 44
            (string)$user['username'],
50 44
            (string)$user['name'],
51 44
            (string)$user['web_url']
52
        );
53
    }
54
55
    /**
56
     * @return int
57
     */
58 9
    public function getId(): int
59
    {
60 9
        return $this->id;
61
    }
62
63
    /**
64
     * @return string
65
     */
66 14
    public function getUsername(): string
67
    {
68 14
        return $this->username;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getName(): string
75
    {
76 1
        return $this->name;
77
    }
78
79
    /**
80
     * @return string
81
     */
82 2
    public function getWebUrl(): string
83
    {
84 2
        return $this->webUrl;
85
    }
86
}
87