OrganisationIdentification   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 34
c 1
b 0
f 0
dl 0
loc 55
ccs 18
cts 22
cp 0.8182
rs 10
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFromXml() 0 51 8
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt\Decoder\Factory\DTO;
6
7
use Genkgo\Camt\DTO;
8
use SimpleXMLElement;
9
10
class OrganisationIdentification
11
{
12
    use Behavior\Mapping;
13
14 23
    public static function createFromXml(SimpleXMLElement $xmlOrganisationIdentification): DTO\OrganisationIdentification
15
    {
16
        $mapping = [
17 23
            ['setter' => 'setBic', 'value' => 'BIC'],
18
            ['setter' => 'setBic', 'value' => 'BICOrBEI'],
19
            ['setter' => 'setBic', 'value' => 'AnyBIC'],
20
            ['setter' => 'setBei', 'value' => 'BICOrBEI'],
21
            ['setter' => 'setIbei', 'value' => 'IBEI'],
22
            ['setter' => 'setBei', 'value' => 'BEI'],
23
            ['setter' => 'setEangln', 'value' => 'EANGLN'],
24
            ['setter' => 'setChipsUniversalId', 'value' => 'USCHU'],
25
            ['setter' => 'setDuns', 'value' => 'DUNS'],
26
            ['setter' => 'setBankPartyId', 'value' => 'BkPtyId'],
27
            ['setter' => 'setTaxId', 'value' => 'TaxIdNb'],
28
        ];
29
30 23
        $organisationIdentification = new DTO\OrganisationIdentification();
31
32 23
        static::map($organisationIdentification, $xmlOrganisationIdentification, $mapping);
33
34 23
        if (isset($xmlOrganisationIdentification->PrtryId)) {
35 4
            $other = $xmlOrganisationIdentification->PrtryId;
36
        }
37 23
        if (isset($xmlOrganisationIdentification->Othr)) {
38 22
            $other = $xmlOrganisationIdentification->Othr;
39
        }
40
41 23
        if (isset($other)) {
42 23
            if (isset($other->Id)) {
43 23
                $organisationIdentification->setOtherId(
44 23
                    (string) $other->Id
45
                );
46
            }
47 23
            if (isset($other->Issr)) {
48 23
                $organisationIdentification->setOtherIssuer(
49 23
                    (string) $other->Issr
50
                );
51
            }
52 23
            if (isset($other->Tp)) {
53
                $organisationIdentification->setOtherType(
54
                    (string) $other->Tp
55
                );
56
            }
57 23
            if (isset($other->SchmeNm)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $other does not seem to be defined for all execution paths leading up to this point.
Loading history...
58
                $organisationIdentification->setOtherSchemeName(
59
                    (string) $other->SchmeNm
60
                );
61
            }
62
        }
63
64 23
        return $organisationIdentification;
65
    }
66
}
67