Completed
Pull Request — master (#167)
by Gorka
02:54
created

Project::organizationId()   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
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId;
20
21
class Project extends AggregateRoot
22
{
23
    private $id;
24
    private $name;
25
    private $slug;
26
    private $createdOn;
27
    private $updatedOn;
28
    private $organizationId;
29
30
    public function __construct(ProjectId $id, ProjectName $name, Slug $slug, OrganizationId $organizationId)
31
    {
32
        $this->id = $id;
33
        $this->name = $name;
34
        $this->slug = $slug;
35
        $this->createdOn = new \DateTimeImmutable();
36
        $this->updatedOn = new \DateTimeImmutable();
37
        $this->organizationId = $organizationId;
38
39
        $this->publish(
40
            new ProjectCreated($id)
41
        );
42
    }
43
44
    public function id() : ProjectId
45
    {
46
        return $this->id;
47
    }
48
49
    public function name() : ProjectName
50
    {
51
        return $this->name;
52
    }
53
54
    public function slug() : Slug
55
    {
56
        return $this->slug;
57
    }
58
59
    public function createdOn() : \DateTimeImmutable
60
    {
61
        return $this->createdOn;
62
    }
63
64
    public function updatedOn() : \DateTimeImmutable
65
    {
66
        return $this->updatedOn;
67
    }
68
69 View Code Duplication
    public function edit(ProjectName $name, Slug $slug)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71
        $this->name = $name;
72
        $this->slug = $slug;
73
        $this->updatedOn = new \DateTimeImmutable();
74
75
        $this->publish(
76
            new ProjectEdited($this->id)
77
        );
78
    }
79
80
    public function __toString() : string
81
    {
82
        return (string) $this->id->id();
83
    }
84
85
    public function organizationId() : OrganizationId
86
    {
87
        return $this->organizationId;
88
    }
89
}
90