User   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
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 52
ccs 12
cts 12
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
declare(strict_types=1);
3
4
namespace N1215\SimpleAdr\Domain;
5
6
use JsonSerializable;
7
8
/**
9
 * User
10
 * @package N1215\SimpleAdr\Domain
11
 */
12
class User implements JsonSerializable
13
{
14
    /**
15
     * @var UserId
16
     */
17
    private $userId;
18
19
    /**
20
     * @var UserName
21
     */
22
    private $userName;
23
24
    /**
25
     * @param UserId $userId
26
     * @param UserName $userName
27
     */
28 5
    public function __construct(UserId $userId, UserName $userName)
29
    {
30 5
        $this->userId = $userId;
31 5
        $this->userName = $userName;
32
    }
33
34
    /**
35
     * @return UserName
36
     */
37 2
    public function getName() : UserName
38
    {
39 2
        return $this->userName;
40
    }
41
42
    /**
43
     * @return UserId
44
     */
45 2
    public function getId() : UserId
46
    {
47 2
        return $this->userId;
48
    }
49
50
    /**
51
     * @return array
52
     */
53 2
    public function jsonSerialize() : array
54
    {
55 2
        $rawId = $this->userId->getValue();
56 2
        $rawName = $this->userName->getValue();
57
58
        return [
59 2
            'id' => $rawId,
60 2
            'name' => $rawName,
61
        ];
62
    }
63
}
64