Completed
Push — master ( 3b3980...4ce207 )
by Gorka
9s
created

Participant::updatedOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Domain\Model\Organization;
16
17
use Kreta\SharedKernel\Domain\Model\Identity\EmailAddress;
18
use Kreta\SharedKernel\Domain\Model\Identity\Username;
19
20
abstract class Participant
21
{
22
    protected $id;
23
    protected $createdOn;
24
    protected $email;
25
    protected $username;
26
    protected $updatedOn;
27
28
    public function __construct(ParticipantId $id, EmailAddress $email, Username $username)
29
    {
30
        $this->id = $id;
31
        $this->email = $email;
32
        $this->username = $username;
33
        $this->createdOn = new \DateTimeImmutable();
34
        $this->updatedOn = new \DateTimeImmutable();
35
    }
36
37
    public function id() : ParticipantId
38
    {
39
        return $this->id;
40
    }
41
42
    public function changeEmail(EmailAddress $email)
43
    {
44
        $this->email = $email;
45
        $this->updatedOn = new \DateTimeImmutable();
46
    }
47
48
    public function changeUsername(Username $username)
49
    {
50
        $this->username = $username;
51
        $this->updatedOn = new \DateTimeImmutable();
52
    }
53
54
    public function createdOn() : \DateTimeInterface
55
    {
56
        return $this->createdOn;
57
    }
58
59
    public function email() : EmailAddress
60
    {
61
        return $this->email;
62
    }
63
64
    public function updatedOn() : \DateTimeInterface
65
    {
66
        return $this->updatedOn;
67
    }
68
69
    public function username() : Username
70
    {
71
        return $this->username;
72
    }
73
74
    public function __toString()
75
    {
76
        return (string) $this->id->id();
77
    }
78
}
79