Passed
Push — master ( cbe288...130872 )
by Peter
02:31
created

Page::getCategoryId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Domain\Entities;
6
7
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
8
use AbterPhp\Website\Domain\Entities\Page\Assets;
9
use AbterPhp\Website\Domain\Entities\Page\Meta;
10
11
class Page implements IStringerEntity
12
{
13
    /** @var string */
14
    protected $id;
15
16
    /** @var string */
17
    protected $identifier;
18
19
    /** @var string */
20
    protected $title;
21
22
    /** @var string */
23
    protected $body;
24
25
    /** @var string|null */
26
    protected $categoryId;
27
28
    /** @var string */
29
    protected $layout;
30
31
    /** @var string|null */
32
    protected $layoutId;
33
34
    /** @var Meta */
35
    protected $meta;
36
37
    /** @var Assets|null */
38
    protected $assets;
39
40
    /**
41
     * Page constructor.
42
     *
43
     * @param string      $id
44
     * @param string      $identifier
45
     * @param string      $title
46
     * @param string      $body
47
     * @param string|null $categoryId
48
     * @param string      $layout
49
     * @param string|null $layoutId
50
     * @param Meta|null   $meta
51
     * @param Assets|null $assets
52
     */
53
    public function __construct(
54
        string $id,
55
        string $identifier,
56
        string $title,
57
        string $body,
58
        ?string $categoryId = null,
59
        string $layout,
60
        ?string $layoutId = null,
61
        ?Meta $meta = null,
62
        ?Assets $assets = null
63
    ) {
64
        $this->id         = $id;
65
        $this->identifier = $identifier;
66
        $this->title      = $title;
67
        $this->body       = $body;
68
        $this->categoryId = $categoryId ? $categoryId : null;
69
        $this->layout     = $layout;
70
        $this->layoutId   = $layoutId ? $layoutId : null;
71
        $this->meta       = $meta ?: new Meta('', '', '', '', '', '', '', '');
72
        $this->assets     = $assets;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getId()
79
    {
80
        return $this->id;
81
    }
82
83
    /**
84
     * @param string $id
85
     */
86
    public function setId($id)
87
    {
88
        $this->id = $id;
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getIdentifier(): string
95
    {
96
        return $this->identifier;
97
    }
98
99
    /**
100
     * @param string $identifier
101
     *
102
     * @return $this
103
     */
104
    public function setIdentifier(string $identifier): Page
105
    {
106
        $this->identifier = $identifier;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getTitle(): string
115
    {
116
        return $this->title;
117
    }
118
119
    /**
120
     * @param string $title
121
     *
122
     * @return $this
123
     */
124
    public function setTitle(string $title): Page
125
    {
126
        $this->title = $title;
127
128
        return $this;
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    public function getBody(): string
135
    {
136
        return $this->body;
137
    }
138
139
    /**
140
     * @param string $body
141
     *
142
     * @return $this
143
     */
144
    public function setBody(string $body): Page
145
    {
146
        $this->body = $body;
147
148
        return $this;
149
    }
150
151
    /**
152
     * @return string|null
153
     */
154
    public function getCategoryId(): ?string
155
    {
156
        return $this->categoryId;
157
    }
158
159
    /**
160
     * @param string|null $categoryId
161
     *
162
     * @return $this
163
     */
164
    public function setCategoryId(?string $categoryId): Page
165
    {
166
        if ($categoryId === '') {
167
            $categoryId = null;
168
        }
169
170
        $this->categoryId = $categoryId;
171
172
        return $this;
173
    }
174
175
    /**
176
     * @return string
177
     */
178
    public function getLayout(): string
179
    {
180
        return $this->layout;
181
    }
182
183
    /**
184
     * @param string $layout
185
     *
186
     * @return $this
187
     */
188
    public function setLayout(string $layout): Page
189
    {
190
        $this->layout = $layout;
191
192
        return $this;
193
    }
194
195
    /**
196
     * @return string|null
197
     */
198
    public function getLayoutId(): ?string
199
    {
200
        return $this->layoutId;
201
    }
202
203
    /**
204
     * @param string|null $layout
205
     *
206
     * @return $this
207
     */
208
    public function setLayoutId(?string $layoutId): Page
209
    {
210
        if ($layoutId === '') {
211
            $layoutId = null;
212
        }
213
214
        $this->layoutId = $layoutId;
215
216
        return $this;
217
    }
218
219
    /**
220
     * @return Meta
221
     */
222
    public function getMeta(): Meta
223
    {
224
        return $this->meta;
225
    }
226
227
    /**
228
     * @param Meta $meta
229
     *
230
     * @return $this
231
     */
232
    public function setMeta(Meta $meta): Page
233
    {
234
        $this->meta = $meta;
235
236
        return $this;
237
    }
238
239
    /**
240
     * @return Assets|null
241
     */
242
    public function getAssets(): ?Assets
243
    {
244
        return $this->assets;
245
    }
246
247
    /**
248
     * @param Assets|null $header
249
     *
250
     * @return $this
251
     */
252
    public function setAssets(?Assets $assets): Page
253
    {
254
        $this->assets = $assets;
255
256
        return $this;
257
    }
258
259
    /**
260
     * @return string
261
     */
262
    public function __toString(): string
263
    {
264
        return $this->getIdentifier();
265
    }
266
}
267