ContentListItem   A
last analyzed

Complexity

Total Complexity 27

Size/Duplication

Total Lines 329
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 71
c 1
b 0
f 0
dl 0
loc 329
rs 10
wmc 27

26 Methods

Rating   Name   Duplication   Size   Complexity  
A getContentHref() 0 3 1
A isDeleted() 0 3 1
A getLabel() 0 3 1
A toData() 0 20 2
A setId() 0 3 1
A __construct() 0 24 1
A toJSON() 0 3 1
A getId() 0 3 1
A getImgAlt() 0 3 1
A setImgAlt() 0 5 1
A setClasses() 0 5 1
A getClasses() 0 3 1
A setImgHref() 0 5 1
A getImgSrc() 0 3 1
A getListId() 0 3 1
A setContent() 0 5 1
A setLabel() 0 5 1
A setListId() 0 5 1
A setImgSrc() 0 5 1
A setContentHref() 0 5 1
A getImgHref() 0 3 1
A setLabelHref() 0 5 1
A setDeleted() 0 5 1
A getLabelHref() 0 3 1
A __toString() 0 3 1
A getContent() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Domain\Entities;
6
7
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
8
9
/**
10
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
11
 */
12
class ContentListItem implements IStringerEntity
13
{
14
    /** @var string */
15
    protected $id;
16
17
    /** @var string */
18
    protected $listId;
19
20
    /** @var string */
21
    protected $label;
22
23
    /** @var string */
24
    protected $labelHref;
25
26
    /** @var string */
27
    protected $content;
28
29
    /** @var string */
30
    protected $contentHref;
31
32
    /** @var string */
33
    protected $imgSrc;
34
35
    /** @var string */
36
    protected $imgAlt;
37
38
    /** @var string */
39
    protected $imgHref;
40
41
    /** @var string */
42
    protected $classes;
43
44
    /** @var bool */
45
    protected $deleted;
46
47
    /**
48
     * ContentListItem constructor.
49
     *
50
     * @param string $id
51
     * @param string $listId
52
     * @param string $label
53
     * @param string $labelHref
54
     * @param string $content
55
     * @param string $contentHref
56
     * @param string $imgSrc
57
     * @param string $imgAlt
58
     * @param string $imgHref
59
     * @param string $classes
60
     * @param bool   $isDeleted
61
     */
62
    public function __construct(
63
        string $id,
64
        string $listId,
65
        string $label,
66
        string $labelHref,
67
        string $content,
68
        string $contentHref,
69
        string $imgSrc,
70
        string $imgAlt,
71
        string $imgHref,
72
        string $classes,
73
        bool $isDeleted = false
74
    ) {
75
        $this->id          = $id;
76
        $this->listId      = $listId;
77
        $this->label       = $label;
78
        $this->labelHref   = $labelHref;
79
        $this->content     = $content;
80
        $this->contentHref = $contentHref;
81
        $this->imgSrc      = $imgSrc;
82
        $this->imgAlt      = $imgAlt;
83
        $this->imgHref     = $imgHref;
84
        $this->classes     = $classes;
85
        $this->deleted     = $isDeleted;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getId()
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @param string $id
98
     */
99
    public function setId($id)
100
    {
101
        $this->id = $id;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getListId(): string
108
    {
109
        return $this->listId;
110
    }
111
112
    /**
113
     * @param string $listId
114
     *
115
     * @return $this
116
     */
117
    public function setListId(string $listId): self
118
    {
119
        $this->listId = $listId;
120
121
        return $this;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getLabel(): string
128
    {
129
        return $this->label;
130
    }
131
132
    /**
133
     * @param string $label
134
     *
135
     * @return $this
136
     */
137
    public function setLabel(string $label): self
138
    {
139
        $this->label = $label;
140
141
        return $this;
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    public function getLabelHref(): string
148
    {
149
        return $this->labelHref;
150
    }
151
152
    /**
153
     * @param string $labelHref
154
     *
155
     * @return $this
156
     */
157
    public function setLabelHref(string $labelHref): self
158
    {
159
        $this->labelHref = $labelHref;
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return string
166
     */
167
    public function getContent(): string
168
    {
169
        return $this->content;
170
    }
171
172
    /**
173
     * @param string $content
174
     *
175
     * @return $this
176
     */
177
    public function setContent(string $content): self
178
    {
179
        $this->content = $content;
180
181
        return $this;
182
    }
183
184
    /**
185
     * @return string
186
     */
187
    public function getContentHref(): string
188
    {
189
        return $this->contentHref;
190
    }
191
192
    /**
193
     * @param string $contentHref
194
     *
195
     * @return $this
196
     */
197
    public function setContentHref(string $contentHref): self
198
    {
199
        $this->contentHref = $contentHref;
200
201
        return $this;
202
    }
203
204
    /**
205
     * @return string
206
     */
207
    public function getImgSrc(): string
208
    {
209
        return $this->imgSrc;
210
    }
211
212
    /**
213
     * @param string $imgSrc
214
     *
215
     * @return $this
216
     */
217
    public function setImgSrc(string $imgSrc): self
218
    {
219
        $this->imgSrc = $imgSrc;
220
221
        return $this;
222
    }
223
224
    /**
225
     * @return string
226
     */
227
    public function getImgAlt(): string
228
    {
229
        return $this->imgAlt;
230
    }
231
232
    /**
233
     * @param string $imgAlt
234
     *
235
     * @return $this
236
     */
237
    public function setImgAlt(string $imgAlt): self
238
    {
239
        $this->imgAlt = $imgAlt;
240
241
        return $this;
242
    }
243
244
    /**
245
     * @return string
246
     */
247
    public function getImgHref(): string
248
    {
249
        return $this->imgHref;
250
    }
251
252
    /**
253
     * @param string $imgHref
254
     *
255
     * @return $this
256
     */
257
    public function setImgHref(string $imgHref): self
258
    {
259
        $this->imgHref = $imgHref;
260
261
        return $this;
262
    }
263
264
    /**
265
     * @return string
266
     */
267
    public function getClasses(): string
268
    {
269
        return $this->classes;
270
    }
271
272
    /**
273
     * @param string $classes
274
     *
275
     * @return $this
276
     */
277
    public function setClasses(string $classes): self
278
    {
279
        $this->classes = $classes;
280
281
        return $this;
282
    }
283
284
    /**
285
     * @return bool
286
     */
287
    public function isDeleted(): bool
288
    {
289
        return $this->deleted;
290
    }
291
292
    /**
293
     * @param bool $deleted
294
     */
295
    public function setDeleted(bool $deleted): self
296
    {
297
        $this->deleted = $deleted;
298
299
        return $this;
300
    }
301
302
    /**
303
     * @return string
304
     */
305
    public function __toString(): string
306
    {
307
        return $this->getLabel();
308
    }
309
310
    /**
311
     * @return array|null
312
     */
313
    public function toData(): ?array
314
    {
315
        if ($this->deleted) {
316
            return null;
317
        }
318
319
        $data = [
320
            'id'           => $this->getId(),
321
            'list_id'      => $this->getListId(),
322
            'label'        => $this->getLabel(),
323
            'label_href'   => $this->getLabelHref(),
324
            'content'      => $this->getContent(),
325
            'content_href' => $this->getContentHref(),
326
            'img_src'      => $this->getImgSrc(),
327
            'img_href'     => $this->getImgHref(),
328
            'img_alt'      => $this->getImgAlt(),
329
            'classes'      => $this->getClasses(),
330
        ];
331
332
        return $data;
333
    }
334
335
    /**
336
     * @return string
337
     */
338
    public function toJSON(): string
339
    {
340
        return json_encode($this->toData());
341
    }
342
}
343