Completed
Pull Request — master (#125)
by Gorka
02:29
created

Project::createdOn()   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
rs 10
c 0
b 0
f 0
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\Project;
16
17
use Kreta\SharedKernel\Domain\Model\AggregateRoot;
18
use Kreta\SharedKernel\Domain\Model\Identity\Slug;
19
20
class Project extends AggregateRoot
21
{
22
    private $id;
23
    private $name;
24
    private $slug;
25
    private $createdOn;
26
27
    public function __construct(ProjectId $id, ProjectName $name, Slug $slug)
28
    {
29
        $this->id = $id;
30
        $this->name = $name;
31
        $this->slug = $slug;
32
        $this->createdOn = new \DateTimeImmutable();
33
34
        $this->publish(
35
            new ProjectCreated($id)
36
        );
37
    }
38
39
    public function id() : ProjectId
40
    {
41
        return $this->id;
42
    }
43
44
    public function name()
45
    {
46
        return $this->name;
47
    }
48
49
    public function slug()
50
    {
51
        return $this->slug;
52
    }
53
54
    public function createdOn() : \DateTimeImmutable
55
    {
56
        return $this->createdOn;
57
    }
58
59
    public function edit(string $name, Slug $slug)
60
    {
61
        $this->name = $name;
62
        $this->slug = $slug;
63
64
        $this->publish(
65
            new ProjectEdited($this->id)
66
        );
67
    }
68
69
    public function __toString() : string
70
    {
71
        return (string) $this->id->id();
72
    }
73
}
74