Media::getCategoryIds()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Yproximite\Api\Model\Media;
5
6
use Yproximite\Api\Model\ModelInterface;
7
8
/**
9
 * Class Media
10
 */
11
class Media implements ModelInterface
12
{
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18
    /**
19
     * @var string
20
     */
21
    private $filename;
22
23
    /**
24
     * @var string
25
     */
26
    private $originalFilename;
27
28
    /**
29
     * @var string
30
     */
31
    private $originalFilenameSlugged;
32
33
    /**
34
     * @var string|null
35
     */
36
    private $description;
37
38
    /**
39
     * @var string|null
40
     */
41
    private $title;
42
43
    /**
44
     * @var bool
45
     */
46
    private $visible;
47
48
    /**
49
     * @var \DateTime
50
     */
51
    private $createdAt;
52
53
    /**
54
     * @var \DateTime
55
     */
56
    private $updatedAt;
57
58
    /**
59
     * @var string
60
     */
61
    private $mime;
62
63
    /**
64
     * @var string
65
     */
66
    private $type;
67
68
    /**
69
     * @var int
70
     */
71
    private $size;
72
73
    /**
74
     * @var string
75
     */
76
    private $extension;
77
78
    /**
79
     * @var int[]
80
     */
81
    private $categoryIds;
82
83
    /**
84
     * @var string|null
85
     */
86
    private $linkUrl;
87
88
    /**
89
     * Media constructor.
90
     *
91
     * @param array $data
92
     */
93
    public function __construct(array $data)
94
    {
95
        $this->id                      = (int) $data['id'];
96
        $this->filename                = (string) $data['filename'];
97
        $this->originalFilename        = (string) $data['originalFilename'];
98
        $this->originalFilenameSlugged = (string) $data['originalFilenameSlugged'];
99
        $this->description             = !empty($data['description']) ? (string) $data['description'] : null;
100
        $this->title                   = !empty($data['title']) ? (string) $data['title'] : null;
101
        $this->visible                 = (bool) $data['visible'];
102
        $this->createdAt               = new \DateTime($data['created_at']);
103
        $this->updatedAt               = new \DateTime($data['updated_at']);
104
        $this->mime                    = (string) $data['mime'];
105
        $this->type                    = (string) $data['type'];
106
        $this->size                    = (int) $data['size'];
107
        $this->extension               = (string) $data['extension'];
108
        $this->categoryIds             = array_map('intval', $data['category_ids']);
109
        $this->linkUrl                 = !empty($data['link_url']) ? (string) $data['link_url'] : null;
110
    }
111
112
    /**
113
     * @return int
114
     */
115
    public function getId(): int
116
    {
117
        return $this->id;
118
    }
119
120
    /**
121
     * @return string
122
     */
123
    public function getFilename(): string
124
    {
125
        return $this->filename;
126
    }
127
128
    /**
129
     * @return string
130
     */
131
    public function getOriginalFilename(): string
132
    {
133
        return $this->originalFilename;
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    public function getOriginalFilenameSlugged(): string
140
    {
141
        return $this->originalFilenameSlugged;
142
    }
143
144
    /**
145
     * @return null|string
146
     */
147
    public function getDescription()
148
    {
149
        return $this->description;
150
    }
151
152
    /**
153
     * @return null|string
154
     */
155
    public function getTitle()
156
    {
157
        return $this->title;
158
    }
159
160
    /**
161
     * @return bool
162
     */
163
    public function isVisible(): bool
164
    {
165
        return $this->visible;
166
    }
167
168
    /**
169
     * @return \DateTime
170
     */
171
    public function getCreatedAt(): \DateTime
172
    {
173
        return $this->createdAt;
174
    }
175
176
    /**
177
     * @return \DateTime
178
     */
179
    public function getUpdatedAt(): \DateTime
180
    {
181
        return $this->updatedAt;
182
    }
183
184
    /**
185
     * @return string
186
     */
187
    public function getMime(): string
188
    {
189
        return $this->mime;
190
    }
191
192
    /**
193
     * @return string
194
     */
195
    public function getType(): string
196
    {
197
        return $this->type;
198
    }
199
200
    /**
201
     * @return int
202
     */
203
    public function getSize(): int
204
    {
205
        return $this->size;
206
    }
207
208
    /**
209
     * @return string
210
     */
211
    public function getExtension(): string
212
    {
213
        return $this->extension;
214
    }
215
216
    /**
217
     * @return \int[]
218
     */
219
    public function getCategoryIds(): array
220
    {
221
        return $this->categoryIds;
222
    }
223
224
    /**
225
     * @return null|string
226
     */
227
    public function getLinkUrl()
228
    {
229
        return $this->linkUrl;
230
    }
231
}
232