Passed
Push — master ( 4e582d...e8c0a3 )
by n
02:48
created

User   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 45
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A getId() 0 4 1
A jsonSerialize() 0 10 1
1
<?php
2
3
namespace N1215\SimpleAdr\Domain;
4
5
class User implements \JsonSerializable
6
{
7
8
    /** @var UserId */
9
    private $userId;
10
11
    /** @var UserName */
12
    private $userName;
13
14 4
    public function __construct(UserId $userId, UserName $userName)
15
    {
16 4
        $this->userId = $userId;
17 4
        $this->userName = $userName;
18 4
    }
19
20
    /**
21
     * ユーザー名を取得
22
     */
23 2
    public function getName() : UserName
24
    {
25 2
        return $this->userName;
26
    }
27
28
    /**
29
     * ユーザーIDを取得
30
     */
31 2
    public function getId() : UserId
32
    {
33 2
        return $this->userId;
34
    }
35
36
    /**
37
     * JSON用の配列に変換
38
     */
39 1
    public function jsonSerialize() : array
40
    {
41 1
        $rawId = $this->userId->getValue();
42 1
        $rawName = $this->userName->getValue();
43
44
        return [
45 1
            'id' => $rawId,
46 1
            'name' => $rawName,
47
        ];
48
    }
49
}