Failed Conditions
Push — master ( 65cf51...40aca8 )
by Adrien
03:16
created

EntryTransactionDetail   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 26.09%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 47
ccs 6
cts 23
cp 0.2609
rs 10
c 0
b 0
f 0
wmc 12

1 Method

Rating   Name   Duplication   Size   Complexity  
C getRelatedPartyAccount() 0 42 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 4
    public function getRelatedPartyAccount(SimpleXMLElement $xmlRelatedPartyTypeAccount = null)
16
    {
17 4
        if ($xmlRelatedPartyTypeAccount !== null) {
18 4
            if (false === isset($xmlRelatedPartyTypeAccount->Id)) {
19 4
                return;
20
            }
21
22 4
            if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) {
23 4
                return new DTO\IbanAccount(new Iban((string)$xmlRelatedPartyTypeAccount->Id->IBAN));
24
            }
25
26
            if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) {
27
                return new DTO\BBANAccount((string)$xmlRelatedPartyTypeAccount->Id->BBAN);
28
            }
29
30
            if (isset($xmlRelatedPartyTypeAccount->Id->UPIC)) {
31
                return new DTO\UPICAccount((string)$xmlRelatedPartyTypeAccount->Id->UPIC);
32
            }
33
34
            if (isset($xmlRelatedPartyTypeAccount->Id->PrtryAcct)) {
35
                return new DTO\ProprietaryAccount((string)$xmlRelatedPartyTypeAccount->Id->PrtryAcct->Id);
36
            }
37
38
            if (isset($xmlRelatedPartyTypeAccount->Id->Othr)) {
39
                $xmlOtherIdentification = $xmlRelatedPartyTypeAccount->Id->Othr;
40
                $otherAccount           = new DTO\OtherAccount((string)$xmlOtherIdentification->Id);
41
42
                if (isset($xmlOtherIdentification->SchmeNm)) {
43
                    if (isset($xmlOtherIdentification->SchmeNm->Cd)) {
44
                        $otherAccount->setSchemeName((string)$xmlOtherIdentification->SchmeNm->Cd);
45
                    }
46
47
                    if (isset($xmlOtherIdentification->SchmeNm->Prtry)) {
48
                        $otherAccount->setSchemeName((string)$xmlOtherIdentification->SchmeNm->Prtry);
49
                    }
50
                }
51
52
                if (isset($xmlOtherIdentification->Issr)) {
53
                    $otherAccount->setIssuer($xmlOtherIdentification->Issr);
54
                }
55
56
                return $otherAccount;
57
            }
58
        }
59
    }
60
}
61