PlainTextElement   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 22
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
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\TextTypeEnum;
16
use App\Slack\MessageBuilder\MessageJsonSerializeTrait;
17
18
class PlainTextElement implements TextElementInterface, SectionBlockElementInterface, ActionsBlockElementInterface, InputBlockElementInterface
19
{
20
    use MessageJsonSerializeTrait;
21
22
    /** @var string */
23
    private $type;
24
    /** @var string */
25
    private $text;
26
    /** @var bool */
27
    private $emoji;
28
29 8
    public function __construct(string $text)
30
    {
31 8
        if (\strlen($text) > 3000) {
32
            throw new \InvalidArgumentException('Text too long!');
33
        }
34
35 8
        $this->type = TextTypeEnum::PLAIN_TEXT;
36 8
        $this->text = $text;
37 8
        $this->emoji = false;
38 8
    }
39
}
40