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

CNTControl::subSegmentKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 2
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