ConfirmationDialogObject   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 34
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 5
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\Object;
14
15
use App\Slack\MessageBuilder\Element\PlainTextElement;
16
use App\Slack\MessageBuilder\Element\TextElementInterface;
17
use App\Slack\MessageBuilder\MessageInterface;
18
use App\Slack\MessageBuilder\MessageJsonSerializeTrait;
19
20
class ConfirmationDialogObject implements MessageInterface
21
{
22
    use MessageJsonSerializeTrait;
23
24
    /** @var PlainTextElement */
25
    private $title;
26
    /** @var TextElementInterface */
27
    private $text;
28
    /** @var PlainTextElement */
29
    private $confirm;
30
    /** @var PlainTextElement */
31
    private $deny;
32
33 2
    public function __construct(string $title, TextElementInterface $text, string $confirm, string $deny)
34
    {
35 2
        if (\strlen($title) > 100) {
36
            throw new \InvalidArgumentException('$title too long!');
37
        }
38 2
        if (\strlen($text->jsonSerialize()['text']) > 300) {
39
            throw new \InvalidArgumentException('$text too long!');
40
        }
41 2
        if (\strlen($confirm) > 30) {
42
            throw new \InvalidArgumentException('$confirm too long!');
43
        }
44 2
        if (\strlen($deny) > 30) {
45
            throw new \InvalidArgumentException('$deny too long!');
46
        }
47
48 2
        $this->title = new PlainTextElement($title);
49 2
        $this->text = $text;
50 2
        $this->confirm = new PlainTextElement($confirm);
51 2
        $this->deny = new PlainTextElement($deny);
52 2
    }
53
}
54