OptionObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 28
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 4
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\MessageInterface;
17
use App\Slack\MessageBuilder\MessageJsonSerializeTrait;
18
19
class OptionObject implements MessageInterface
20
{
21
    use MessageJsonSerializeTrait;
22
23
    /** @var PlainTextElement */
24
    private $text;
25
    /** @var string */
26
    private $value;
27
    /** @var string */
28
    private $url;
29
30 4
    public function __construct(string $text, string $value, string $url = '')
31
    {
32 4
        if (\strlen($text) > 75) {
33
            throw new \InvalidArgumentException('$text too long!');
34
        }
35 4
        if (\strlen($value) > 75) {
36
            throw new \InvalidArgumentException('$value too long!');
37
        }
38 4
        if (\strlen($url) > 3000) {
39
            throw new \InvalidArgumentException('$url too long!');
40
        }
41
42 4
        $this->text = new PlainTextElement($text);
43 4
        $this->value = $value;
44 4
        $this->url = $url;
45 4
    }
46
}
47