ImageElement   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
1
<?php
2
3
/** @noinspection UnusedConstructorDependenciesInspection */
4
5
declare(strict_types=1);
6
7
/*
8
 * This file is part of the zibios/sharep.
9
 *
10
 * (c) Zbigniew Ślązak
11
 */
12
13
namespace App\Slack\MessageBuilder\Element;
14
15
use App\Slack\MessageBuilder\Enum\MessageTypeEnum;
16
use App\Slack\MessageBuilder\MessageJsonSerializeTrait;
17
18
class ImageElement implements SectionBlockElementInterface, ContextBlockElementInterface
19
{
20
    use MessageJsonSerializeTrait;
21
22
    /** @var string */
23
    private $type;
24
    /** @var string */
25
    private $imageUrl;
26
    /** @var string */
27
    private $altText;
28
29 1
    public function __construct(string $imageUrl, string $altText)
30
    {
31 1
        if (\strlen($imageUrl) > 3000) {
32
            throw new \InvalidArgumentException('$imageUrl too long!');
33
        }
34 1
        if (\strlen($altText) > 2000) {
35
            throw new \InvalidArgumentException('$altText too long!');
36
        }
37
38 1
        $this->type = MessageTypeEnum::ELEMENT_IMAGE;
39 1
        $this->imageUrl = $imageUrl;
40 1
        $this->altText = $altText;
41 1
    }
42
}
43