Completed
Pull Request — master (#6)
by Michał
01:47
created

Note::setUserId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Barenote\Domain;
3
4
use Barenote\Domain\Identity\CategoryId;
5
use Barenote\Domain\Identity\NoteId;
6
use Barenote\Domain\Identity\UserId;
7
8
class Note implements \JsonSerializable
9
{
10
    /**
11
     * @var NoteId
12
     */
13
    private $id;
14
    /**
15
     * @var UserId
16
     */
17
    private $userId;
18
    /**
19
     * @var CategoryId
20
     */
21
    private $categoryId;
22
    /**
23
     * @var string
24
     */
25
    private $title;
26
    /**
27
     * @var string
28
     */
29
    private $content;
30
31
    public function __construct()
32
    {
33
    }
34
35
    /**
36
     * @return UserId
37
     */
38
    public function getUserId()
39
    {
40
        return $this->userId;
41
    }
42
43
    /**
44
     * @param UserId $userId
45
     * @return Note
46
     */
47
    public function setUserId(UserId $userId)
48
    {
49
        $this->userId = $userId;
50
51
        return $this;
52
    }
53
54
    /**
55
     * @return CategoryId
56
     */
57
    public function getCategoryId()
58
    {
59
        return $this->categoryId;
60
    }
61
62
    /**
63
     * @param CategoryId $categoryId
64
     * @return Note
65
     */
66
    public function setCategoryId(CategoryId $categoryId)
67
    {
68
        $this->categoryId = $categoryId;
69
70
        return $this;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getTitle()
77
    {
78
        return $this->title;
79
    }
80
81
    /**
82
     * @param string $title
83
     * @return Note
84
     */
85
    public function setTitle(string $title)
86
    {
87
        $this->title = $title;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getContent()
96
    {
97
        return $this->content;
98
    }
99
100
    /**
101
     * @param string $content
102
     * @return Note
103
     */
104
    public function setContent(string $content)
105
    {
106
        $this->content = $content;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return array
113
     */
114
    public function jsonSerialize()
115
    {
116
        return [
117
            'id'          => $this->getId() === null ?: $this->getId()->getValue(),
118
            'user_id'     => $this->userId->getValue(),
119
            'category_id' => $this->categoryId->getValue(),
120
            'title'       => $this->title,
121
            'content'     => $this->content
122
        ];
123
    }
124
125
    /**
126
     * @return NoteId
127
     */
128
    public function getId()
129
    {
130
        return $this->id;
131
    }
132
133
    /**
134
     * @param NoteId $id
135
     * @return Note
136
     */
137
    public function setId(NoteId $id)
138
    {
139
        $this->id = $id;
140
141
        return $this;
142
    }
143
}