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

SegmentFactory::factory()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 10.2655

Importance

Changes 0
Metric Value
cc 9
eloc 19
nc 9
nop 1
dl 0
loc 24
ccs 15
cts 20
cp 0.75
crap 10.2655
rs 8.0555
c 0
b 0
f 0
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