PlainTextElement::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 7
cp 0.8571
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0116
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