Test Failed
Push — master ( d641b2...b856ab )
by Jan
03:23
created

Embed::getUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace DiscordWebhook;
5
6
use DateTime;
7
use DiscordWebhook\Embed\Author;
8
use DiscordWebhook\Embed\Field;
9
use DiscordWebhook\Embed\Footer;
10
use DiscordWebhook\Embed\Image;
11
use DiscordWebhook\Embed\Provider;
12
use DiscordWebhook\Embed\Thumbnail;
13
use DiscordWebhook\Embed\Video;
14
use Doctrine\Common\Collections\ArrayCollection;
15
16
/**
17
 * Class Embed
18
 *
19
 * @author Scrummer <[email protected]>
20
 * @package DiscordWebhook
21
 */
22
class Embed
23
{
24
    /**
25
     * Embed base config
26
     */
27
    public const CONFIG_MAX_COUNT = 10;
28
29
    /**
30
     * Embed colors
31
     */
32
    public const COLOR_DEFAULT     = 0;
33
    public const COLOR_AQUA        = 1752220;
34
    public const COLOR_GREEN       = 3066993;
35
    public const COLOR_BLUE        = 3447003;
36
    public const COLOR_PURPLE      = 10181046;
37
    public const COLOR_GOLD        = 15844367;
38
    public const COLOR_ORANGE      = 15105570;
39
    public const COLOR_RED         = 15158332;
40
    public const COLOR_GREY        = 9807270;
41
    public const COLOR_DARKER_GREY = 8359053;
42
    public const COLOR_NAVY        = 3426654;
43
    public const COLOR_DARK_AQUA   = 1146986;
44
    public const COLOR_DARK_GREEN  = 2067276;
45
    public const COLOR_DARK_BLUE   = 2123412;
46
    public const COLOR_DARK_PURPLE = 7419530;
47
    public const COLOR_DARK_GOLD   = 12745742;
48
    public const COLOR_DARK_ORANGE = 11027200;
49
    public const COLOR_DARK_RED    = 10038562;
50
    public const COLOR_DARK_GREY   = 9936031;
51
    public const COLOR_LIGHT_GREY  = 12370112;
52
    public const COLOR_DARK_NAVY   = 2899536;
53
54
    /**
55
     * @var string|null
56
     */
57
    private $title;
58
59
    /**
60
     * @var string|null
61
     */
62
    private $type = 'rich';
63
64
    /**
65
     * @var string|null
66
     */
67
    private $description;
68
69
    /**
70
     * @var string|null
71
     */
72
    private $url;
73
74
    /**
75
     * @var DateTime|null
76
     */
77
    private $timestamp;
78
79
    /**
80
     * @var int|null
81
     */
82
    private $color;
83
84
    /**
85
     * @var Footer|null
86
     */
87
    private $footer;
88
89
    /**
90
     * @var Image|null
91
     */
92
    private $image;
93
94
    /**
95
     * @var Thumbnail|null
96
     */
97
    private $thumbnail;
98
99
    /**
100
     * @var Video|null
101
     */
102
    private $video;
103
104
    /**
105
     * @var Provider|null
106
     */
107
    private $provider;
108
109
    /**
110
     * @var Author|null
111
     */
112
    private $author;
113
114
    /**
115
     * @var Field[]|ArrayCollection|null
116
     */
117
    private $fields;
118
119
    public function __construct()
120
    {
121
        $this->fields = new ArrayCollection();
122
    }
123
124
    /**
125
     * @return string|null
126
     */
127
    public function getTitle(): ?string
128
    {
129
        return $this->title;
130
    }
131
132
    /**
133
     * @param string|null $title
134
     *
135
     * @return Embed
136
     */
137
    public function setTitle(?string $title): Embed
138
    {
139
        $this->title = $title;
140
141
        return $this;
142
    }
143
144
    /**
145
     * @return string|null
146
     */
147
    public function getType(): ?string
148
    {
149
        return $this->type;
150
    }
151
152
    /**
153
     * @param string|null $type
154
     *
155
     * @return Embed
156
     */
157
    public function setType(?string $type): Embed
158
    {
159
        $this->type = $type;
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return string|null
166
     */
167
    public function getDescription(): ?string
168
    {
169
        return $this->description;
170
    }
171
172
    /**
173
     * @param string|null $description
174
     *
175
     * @return Embed
176
     */
177
    public function setDescription(?string $description): Embed
178
    {
179
        $this->description = $description;
180
181
        return $this;
182
    }
183
184
    /**
185
     * @return string|null
186
     */
187
    public function getUrl(): ?string
188
    {
189
        return $this->url;
190
    }
191
192
    /**
193
     * @param string|null $url
194
     *
195
     * @return Embed
196
     */
197
    public function setUrl(?string $url): Embed
198
    {
199
        $this->url = $url;
200
201
        return $this;
202
    }
203
204
    /**
205
     * @return DateTime|null
206
     */
207
    public function getTimestamp(): ?DateTime
208
    {
209
        return $this->timestamp;
210
    }
211
212
    /**
213
     * @param DateTime|null $timestamp
214
     *
215
     * @return Embed
216
     */
217
    public function setTimestamp(?DateTime $timestamp): Embed
218
    {
219
        $this->timestamp = $timestamp;
220
221
        return $this;
222
    }
223
224
    /**
225
     * @return int|null
226
     */
227
    public function getColor(): ?int
228
    {
229
        return $this->color;
230
    }
231
232
    /**
233
     * @param int|null $color
234
     *
235
     * @return Embed
236
     */
237
    public function setColor(?int $color): Embed
238
    {
239
        $this->color = $color;
240
241
        return $this;
242
    }
243
244
    /**
245
     * @return Footer|null
246
     */
247
    public function getFooter(): ?Footer
248
    {
249
        return $this->footer;
250
    }
251
252
    /**
253
     * @param Footer|null $footer
254
     *
255
     * @return Embed
256
     */
257
    public function setFooter(?Footer $footer): Embed
258
    {
259
        $this->footer = $footer;
260
261
        return $this;
262
    }
263
264
    /**
265
     * @return Image|null
266
     */
267
    public function getImage(): ?Image
268
    {
269
        return $this->image;
270
    }
271
272
    /**
273
     * @param Image|null $image
274
     *
275
     * @return Embed
276
     */
277
    public function setImage(?Image $image): Embed
278
    {
279
        $this->image = $image;
280
281
        return $this;
282
    }
283
284
    /**
285
     * @return Thumbnail|null
286
     */
287
    public function getThumbnail(): ?Thumbnail
288
    {
289
        return $this->thumbnail;
290
    }
291
292
    /**
293
     * @param Thumbnail|null $thumbnail
294
     *
295
     * @return Embed
296
     */
297
    public function setThumbnail(?Thumbnail $thumbnail): Embed
298
    {
299
        $this->thumbnail = $thumbnail;
300
301
        return $this;
302
    }
303
304
    /**
305
     * @return Video|null
306
     */
307
    public function getVideo(): ?Video
308
    {
309
        return $this->video;
310
    }
311
312
    /**
313
     * @param Video|null $video
314
     *
315
     * @return Embed
316
     */
317
    public function setVideo(?Video $video): Embed
318
    {
319
        $this->video = $video;
320
321
        return $this;
322
    }
323
324
    /**
325
     * @return Provider|null
326
     */
327
    public function getProvider(): ?Provider
328
    {
329
        return $this->provider;
330
    }
331
332
    /**
333
     * @param Provider|null $provider
334
     *
335
     * @return Embed
336
     */
337
    public function setProvider(?Provider $provider): Embed
338
    {
339
        $this->provider = $provider;
340
341
        return $this;
342
    }
343
344
    /**
345
     * @return Author|null
346
     */
347
    public function getAuthor(): ?Author
348
    {
349
        return $this->author;
350
    }
351
352
    /**
353
     * @param Author|null $author
354
     *
355
     * @return Embed
356
     */
357
    public function setAuthor(?Author $author): Embed
358
    {
359
        $this->author = $author;
360
361
        return $this;
362
    }
363
364
    /**
365
     * @return Field[]|ArrayCollection|null
366
     */
367
    public function getFields()
368
    {
369
        return $this->fields->isEmpty() ? null : $this->fields->toArray();
0 ignored issues
show
Bug introduced by
The method isEmpty() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

369
        return $this->fields->/** @scrutinizer ignore-call */ isEmpty() ? null : $this->fields->toArray();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
370
    }
371
372
    /**
373
     * @param Field $field
374
     *
375
     * @return Embed
376
     */
377
    public function addField(Field $field): Embed
378
    {
379
        $this->fields->add($field);
380
381
        return $this;
382
    }
383
}
384