Passed
Push — master ( ed8f97...95efe5 )
by Chema
03:24
created

UnknownSegment   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A subSegmentKey() 0 5 2
A rawValues() 0 3 1
A __construct() 0 3 1
A name() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdifactParser\Segments;
6
7
final class UnknownSegment implements SegmentInterface
8
{
9
    public const NAME = 'Unknown';
10
11
    /** @var array */
12
    private $rawValues;
13
14 5
    public function __construct(array $rawValues)
15
    {
16 5
        $this->rawValues = $rawValues;
17 5
    }
18
19 5
    public function name(): string
20
    {
21 5
        return self::NAME;
22
    }
23
24 5
    public function subSegmentKey(): string
25
    {
26 5
        $encodedValues = json_encode($this->rawValues);
27
28 5
        return ($encodedValues) ? md5($encodedValues) : md5(self::NAME);
29
    }
30
31 1
    public function rawValues(): array
32
    {
33 1
        return $this->rawValues;
34
    }
35
}
36