Completed
Push — master ( 685a37...c037a4 )
by Nil
04:54
created

User::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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