Passed
Pull Request — master (#3)
by Chema
07:57
created

SegmentFactory::customSegment()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdifactParser\Segments;
6
7
/** @psalmphp-immutable */
8
final class SegmentFactory implements SegmentFactoryInterface
9
{
10 8
    public function segmentFromArray(array $rawArray): SegmentInterface
11
    {
12 8
        $name = $rawArray[0];
13
14 8
        switch ($name) {
15 8
            case 'UNH':
16 8
                return new UNHMessageHeader($rawArray);
17 7
            case 'DTM':
18 1
                return new DTMDateTimePeriod($rawArray);
19 7
            case 'NAD':
20 1
                return new NADNameAddress($rawArray);
21 7
            case 'MEA':
22 1
                return new MEADimensions($rawArray);
23 7
            case 'CNT':
24 4
                return new CNTControl($rawArray);
25 7
            case 'PCI':
26 1
                return new PCIPackageId($rawArray);
27 7
            case 'BGM':
28 1
                return new BGMBeginningOfMessage($rawArray);
29 7
            case 'UNT':
30 7
                return new UNTMessageFooter($rawArray);
31
        }
32
33 6
        return new UnknownSegment($rawArray);
34
    }
35
}
36