Passed
Pull Request — master (#5)
by Chema
04:15
created

DTMDateTimePeriod   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

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

4 Methods

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