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

SegmentFactory   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 26
ccs 15
cts 20
cp 0.75
rs 10
c 0
b 0
f 0
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B factory() 0 24 9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdifactParser\Segments;
6
7
final class SegmentFactory
8
{
9 7
    public static function factory(array $rawArray): SegmentInterface
10
    {
11 7
        $name = $rawArray[0];
12
13 7
        switch ($name) {
14 7
            case 'UNH':
15 7
                return new UNHMessageHeader($rawArray);
16 5
            case 'DTM':
17
                return new DTMDateTimePeriod($rawArray);
18 5
            case 'NAD':
19
                return new NADNameAddress($rawArray);
20 5
            case 'MEA':
21
                return new MEADimensions($rawArray);
22 5
            case 'CNT':
23 2
                return new CNTControl($rawArray);
24 5
            case 'PCI':
25
                return new PCIPackageId($rawArray);
26 5
            case 'BGM':
27
                return new BGMBeginningOfMessage($rawArray);
28 5
            case 'UNT':
29 5
                return new UNTMessageFooter($rawArray);
30
        }
31
32 4
        return new UnknownSegment($rawArray);
33
    }
34
}
35