Completed
Push — master ( 45d8dc...fe9038 )
by Frederik
02:32
created

EntryTransactionDetail   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 53
ccs 6
cts 24
cp 0.25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C getRelatedPartyAccount() 0 47 12
1
<?php
2
3
namespace Genkgo\Camt\Camt054\Decoder;
4
5
use Genkgo\Camt\DTO;
6
use Genkgo\Camt\Decoder\EntryTransactionDetail as BaseDecoder;
7
use \SimpleXMLElement;
8
use Genkgo\Camt\Iban;
9
10
class EntryTransactionDetail extends BaseDecoder
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 3
    public function getRelatedPartyAccount(SimpleXMLElement $xmlRelatedPartyTypeAccount = null)
16
    {
17
18 3
        if ($xmlRelatedPartyTypeAccount !== null) {
19
20 3
            if (false === isset($xmlRelatedPartyTypeAccount->Id)) {
21 3
                return;
22
            }
23
24 3
            if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
25 3
                return new DTO\IbanAccount(new Iban((string)$xmlRelatedPartyTypeAccount->Id->IBAN));
26
            }
27
28
            if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {
29
                return new DTO\BBANAccount((string)$xmlRelatedPartyTypeAccount->Id->BBAN);
30
            }
31
32
            if (isset($xmlRelatedPartyTypeAccount->Id->UPIC)) {
33
                return new DTO\UPICAccount((string)$xmlRelatedPartyTypeAccount->Id->UPIC);
34
            }
35
36
            if (isset($xmlRelatedPartyTypeAccount->Id->PrtryAcct)) {
37
                return new DTO\ProprietaryAccount((string)$xmlRelatedPartyTypeAccount->Id->PrtryAcct->Id);
38
            }
39
40
            if (isset($xmlRelatedPartyTypeAccount->Id->Othr)) {
41
                $xmlOtherIdentification = $xmlRelatedPartyTypeAccount->Id->Othr;
42
                $otherAccount           = new DTO\OtherAccount((string)$xmlOtherIdentification->Id);
43
44
                if (isset($xmlOtherIdentification->SchmeNm)) {
45
                    if (isset($xmlOtherIdentification->SchmeNm->Cd)) {
46
                        $otherAccount->setSchemeName((string)$xmlOtherIdentification->SchmeNm->Cd);
47
                    }
48
49
                    if (isset($xmlOtherIdentification->SchmeNm->Prtry)) {
50
                        $otherAccount->setSchemeName((string)$xmlOtherIdentification->SchmeNm->Prtry);
51
                    }
52
                }
53
54
                if (isset($xmlOtherIdentification->Issr)) {
55
                    $otherAccount->setIssuer($xmlOtherIdentification->Issr);
56
                }
57
58
                return $otherAccount;
59
            }
60
        }
61
    }
62
}
63