Image   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 4 1
A getAllowedExtensions() 0 4 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