Image::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Message\Attachment;
6
7
use Kerox\Messenger\Model\Message\AbstractAttachment;
8
9
class Image extends File
10
{
11
    protected const ALLOWED_EXTENSIONS = ['jpg', 'png', 'gif'];
12
13
    /**
14
     * Image constructor.
15
     *
16
     * @throws \Kerox\Messenger\Exception\MessengerException
17
     */
18 2
    public function __construct(string $url, ?bool $reusable = null)
19
    {
20 2
        $this->isValidExtension($url, $this->getAllowedExtensions());
21
22 2
        parent::__construct($url, $reusable, AbstractAttachment::TYPE_IMAGE);
23 2
    }
24
25
    /**
26
     * @throws \Kerox\Messenger\Exception\MessengerException
27
     *
28
     * @return \Kerox\Messenger\Model\Message\Attachment\File
29
     */
30 1
    public static function create(string $url, ?bool $reusable = null): File
31
    {
32 1
        return new self($url, $reusable);
33
    }
34
35 2
    protected function getAllowedExtensions(): array
36
    {
37 2
        return self::ALLOWED_EXTENSIONS;
38
    }
39
}
40