OptionGroupObject::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.432

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 10
cp 0.7
rs 9.7666
c 0
b 0
f 0
cc 4
nc 4
nop 2
crap 4.432
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 OptionGroupObject implements MessageInterface
20
{
21
    use MessageJsonSerializeTrait;
22
23
    /** @var PlainTextElement */
24
    private $label;
25
    /** @var array|OptionObject[] */
26
    private $options;
27
28 2
    public function __construct(string $label, OptionObject ...$options)
29
    {
30 2
        if (\strlen($label) > 75) {
31
            throw new \InvalidArgumentException('$label too long!');
32
        }
33 2
        if (\count($options) > 100) {
34
            throw new \InvalidArgumentException('$options too long!');
35
        }
36 2
        if (0 === \count($options)) {
37
            throw new \InvalidArgumentException('$options too short!');
38
        }
39
40 2
        $this->label = new PlainTextElement($label);
41 2
        $this->options = $options;
42 2
    }
43
}
44