Passed
Push — master ( 8f0f73...d2306b )
by Peter
02:30
created

ContentListItem::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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\Framework\Helper\DateHelper;
9
10
/**
11
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
12
 */
13
class ContentListItem implements IStringerEntity
14
{
15
    /** @var string */
16
    protected $id;
17
18
    /** @var string */
19
    protected $listId;
20
21
    /** @var string */
22
    protected $name;
23
24
    /** @var string */
25
    protected $nameHref;
26
27
    /** @var string */
28
    protected $body;
29
30
    /** @var string */
31
    protected $bodyHref;
32
33
    /** @var string */
34
    protected $imgSrc;
35
36
    /** @var string */
37
    protected $imgHref;
38
39
    /** @var string */
40
    protected $imgAlt;
41
42
    /**
43
     * ContentListItem constructor.
44
     *
45
     * @param string        $id
46
     * @param string        $listId
47
     * @param string        $name
48
     * @param string        $nameHref
49
     * @param string        $body
50
     * @param string        $bodyHref
51
     * @param string        $imgSrc
52
     * @param string        $imgHref
53
     * @param string        $imgAlt
54
     */
55
    public function __construct(
56
        string $id,
57
        string $listId,
58
        string $name,
59
        string $nameHref,
60
        string $body,
61
        string $bodyHref,
62
        string $imgSrc,
63
        string $imgHref,
64
        string $imgAlt
65
    ) {
66
        $this->id        = $id;
67
        $this->listId    = $listId;
68
        $this->name      = $name;
69
        $this->nameHref  = $nameHref;
70
        $this->body      = $body;
71
        $this->bodyHref  = $bodyHref;
72
        $this->imgSrc    = $imgSrc;
73
        $this->imgHref   = $imgHref;
74
        $this->imgAlt    = $imgAlt;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getId()
81
    {
82
        return $this->id;
83
    }
84
85
    /**
86
     * @param string $id
87
     */
88
    public function setId($id)
89
    {
90
        $this->id = $id;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getListId(): string
97
    {
98
        return $this->listId;
99
    }
100
101
    /**
102
     * @param string $listId
103
     *
104
     * @return $this
105
     */
106
    public function setListId(string $listId): ContentListItem
107
    {
108
        $this->listId = $listId;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @return string
115
     */
116
    public function getName(): string
117
    {
118
        return $this->name;
119
    }
120
121
    /**
122
     * @param string $name
123
     *
124
     * @return $this
125
     */
126
    public function setName(string $name): ContentListItem
127
    {
128
        $this->name = $name;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getNameHref(): string
137
    {
138
        return $this->nameHref;
139
    }
140
141
    /**
142
     * @param string $nameHref
143
     *
144
     * @return $this
145
     */
146
    public function setNameHref(string $nameHref): ContentListItem
147
    {
148
        $this->nameHref = $nameHref;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return string
155
     */
156
    public function getBody(): string
157
    {
158
        return $this->body;
159
    }
160
161
    /**
162
     * @param string $body
163
     *
164
     * @return $this
165
     */
166
    public function setBody(string $body): ContentListItem
167
    {
168
        $this->body = $body;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @return string
175
     */
176
    public function getBodyHref(): string
177
    {
178
        return $this->bodyHref;
179
    }
180
181
    /**
182
     * @param string $bodyHref
183
     *
184
     * @return $this
185
     */
186
    public function setBodyHref(string $bodyHref): ContentListItem
187
    {
188
        $this->bodyHref = $bodyHref;
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return string
195
     */
196
    public function getImgSrc(): string
197
    {
198
        return $this->imgSrc;
199
    }
200
201
    /**
202
     * @param string $imgSrc
203
     *
204
     * @return $this
205
     */
206
    public function setImgSrc(string $imgSrc): ContentListItem
207
    {
208
        $this->imgSrc = $imgSrc;
209
210
        return $this;
211
    }
212
213
    /**
214
     * @return string
215
     */
216
    public function getImgHref(): string
217
    {
218
        return $this->imgHref;
219
    }
220
221
    /**
222
     * @param string $imgHref
223
     *
224
     * @return $this
225
     */
226
    public function setImgHref(string $imgHref): ContentListItem
227
    {
228
        $this->imgHref = $imgHref;
229
230
        return $this;
231
    }
232
233
    /**
234
     * @return string
235
     */
236
    public function getImgAlt(): string
237
    {
238
        return $this->imgAlt;
239
    }
240
241
    /**
242
     * @param string $imgAlt
243
     *
244
     * @return $this
245
     */
246
    public function setImgAlt(string $imgAlt): ContentListItem
247
    {
248
        $this->imgAlt = $imgAlt;
249
250
        return $this;
251
    }
252
253
    /**
254
     * @return string
255
     */
256
    public function __toString(): string
257
    {
258
        return $this->getName();
259
    }
260
261
    /**
262
     * @return array
263
     */
264
    public function getData(): array
265
    {
266
        $data = [
267
            'id'        => $this->getId(),
268
            'list_id'   => $this->getListId(),
269
            'name'      => $this->getName(),
270
            'name_href' => $this->getNameHref(),
271
            'body'      => $this->getBody(),
272
            'body_href' => $this->getBodyHref(),
273
            'img_src'   => $this->getImgSrc(),
274
            'img_href'  => $this->getImgHref(),
275
            'img_alt'   => $this->getImgAlt(),
276
        ];
277
278
        return $data;
279
    }
280
281
    /**
282
     * @return string
283
     */
284
    public function toJSON(): string
285
    {
286
        return json_encode($this->getData());
287
    }
288
}
289