OptionGroupObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 25
ccs 7
cts 10
cp 0.7
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 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 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