Completed
Push — master ( ee61c0...1ce428 )
by Adrien
03:11
created

EntryTransactionDetail   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 24%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 53
ccs 6
cts 25
cp 0.24
rs 10
wmc 12

1 Method

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