OptionObject::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.3244

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 11
cp 0.7272
rs 9.7333
c 0
b 0
f 0
cc 4
nc 4
nop 3
crap 4.3244
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