User   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 75
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A userId() 0 4 1
A name() 0 4 1
A registrationDate() 0 4 1
A id() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace NilPortugues\Example\Domain;
4
5
use DateTimeImmutable;
6
use NilPortugues\Foundation\Domain\Model\Repository\Contracts\Identity;
7
8
class User implements Identity
9
{
10
    /**
11
     * @var UserId
12
     */
13
    protected $userId;
14
    /**
15
     * @var string
16
     */
17
    protected $name;
18
    /**
19
     * @var \DateTimeImmutable
20
     */
21
    protected $registrationDate;
22
23
    /**
24
     * User constructor.
25
     *
26
     * @param UserId            $id
27
     * @param string            $name
28
     * @param DateTimeImmutable $registrationDate
29
     */
30
    public function __construct(UserId $id, $name, DateTimeImmutable $registrationDate)
31
    {
32
        $this->userId = $id;
33
        $this->name = $name;
34
        $this->registrationDate = $registrationDate;
35
    }
36
37
    /**
38
     * Returns value for userId property.
39
     *
40
     * @return UserId
41
     */
42
    public function userId()
43
    {
44
        return $this->userId;
45
    }
46
47
    /**
48
     * Returns value for name property.
49
     *
50
     * @return string
51
     */
52
    public function name()
53
    {
54
        return $this->name;
55
    }
56
57
    /**
58
     * Returns value for registrationDate property.
59
     *
60
     * @return DateTimeImmutable
61
     */
62
    public function registrationDate()
63
    {
64
        return $this->registrationDate;
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function id()
71
    {
72
        return $this->userId()->id();
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function __toString()
79
    {
80
        return (string) $this->id();
81
    }
82
}
83