EntryTransactionDetail   A
last analyzed

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