Completed
Pull Request — master (#7)
by Michał
06:27 queued 04:37
created

Note::getTitle()   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
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 $tags;
26
    /**
27
     * @var string
28
     */
29
    private $title;
30
    /**
31
     * @var string
32
     */
33
    private $content;
34
35
    public function __construct()
36
    {
37
    }
38
39
    /**
40
     * @return UserId
41
     */
42
    public function getUserId()
43
    {
44
        return $this->userId;
45
    }
46
47
    /**
48
     * @param UserId $userId
49
     * @return Note
50
     */
51
    public function setUserId(UserId $userId)
52
    {
53
        $this->userId = $userId;
54
55
        return $this;
56
    }
57
58
    /**
59
     * @return CategoryId
60
     */
61
    public function getCategoryId()
62
    {
63
        return $this->categoryId;
64
    }
65
66
    /**
67
     * @param CategoryId $categoryId
68
     * @return Note
69
     */
70
    public function setCategoryId(CategoryId $categoryId)
71
    {
72
        $this->categoryId = $categoryId;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return \string[]
0 ignored issues
show
Documentation introduced by
Should the return type not be string[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
79
     */
80
    public function getTags()
81
    {
82
        return $this->tags;
83
    }
84
85
    /**
86
     * @param \string[] $tags
87
     * @return Note
88
     */
89
    public function setTags(array $tags)
90
    {
91
        $this->tags = $tags;
0 ignored issues
show
Documentation Bug introduced by
It seems like $tags of type array<integer,object<string>> is incompatible with the declared type array<integer,string> of property $tags.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
92
93
        return $this;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getTitle()
100
    {
101
        return $this->title;
102
    }
103
104
    /**
105
     * @param string $title
106
     * @return Note
107
     */
108
    public function setTitle(string $title)
109
    {
110
        $this->title = $title;
111
112
        return $this;
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getContent()
119
    {
120
        return $this->content;
121
    }
122
123
    /**
124
     * @param string $content
125
     * @return Note
126
     */
127
    public function setContent(string $content)
128
    {
129
        $this->content = $content;
130
131
        return $this;
132
    }
133
134
    function jsonSerialize()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
135
    {
136
        return [
137
            'id'          => $this->getId() === null ?: $this->getId()->getValue(),
138
            'user_id'     => $this->userId->getValue(),
139
            'category_id' => $this->categoryId->getValue(),
140
            'title'       => $this->title,
141
            'content'     => $this->content
142
        ];
143
    }
144
145
    /**
146
     * @return NoteId
147
     */
148
    public function getId()
149
    {
150
        return $this->id;
151
    }
152
153
    /**
154
     * @param NoteId $id
155
     * @return Note
156
     */
157
    public function setId(NoteId $id)
158
    {
159
        $this->id = $id;
160
161
        return $this;
162
    }
163
}