Passed
Push — master ( 6a73f4...298deb )
by Chema
02:27 queued 12s
created

CNTControl   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 26
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A name() 0 3 1
A subSegmentKey() 0 7 2
A rawValues() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdifactParser\Segments;
6
7
namespace EdifactParser\Segments;
8
9
use EdifactParser\Exception\MissingSubSegmentKey;
10
11
/** @psalm-immutable */
12
final class CNTControl implements SegmentInterface
13
{
14
    private array $rawValues;
15
16 7
    public function __construct(array $rawValues)
17
    {
18 7
        $this->rawValues = $rawValues;
19 7
    }
20
21 4
    public function name(): string
22
    {
23 4
        return self::class;
24
    }
25
26 5
    public function subSegmentKey(): string
27
    {
28 5
        if (!isset($this->rawValues[1][0])) {
29 1
            throw new MissingSubSegmentKey('[1][0]', $this->rawValues);
30
        }
31
32 4
        return (string)$this->rawValues[1][0];
33
    }
34
35 3
    public function rawValues(): array
36
    {
37 3
        return $this->rawValues;
38
    }
39
}
40