EntryTransactionDetail   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 31.58%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 19
c 2
b 0
f 0
dl 0
loc 41
ccs 6
cts 19
cp 0.3158
rs 10
wmc 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getRelatedPartyAccount() 0 36 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt\Camt053\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 12
    public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAccount): ?DTO\Account
18
    {
19 12
        if (!$xmlRelatedPartyTypeAccount) {
20 5
            return null;
21
        }
22
23 12
        if (false === isset($xmlRelatedPartyTypeAccount->Id)) {
24
            return null;
25
        }
26
27 12
        if (isset($xmlRelatedPartyTypeAccount->Id->IBAN) && $ibanCode = (string) $xmlRelatedPartyTypeAccount->Id->IBAN) {
28 12
            return new DTO\IbanAccount(new Iban($ibanCode));
29
        }
30
31
        if (false === isset($xmlRelatedPartyTypeAccount->Id->Othr)) {
32
            return null;
33
        }
34
35
        $xmlOtherIdentification = $xmlRelatedPartyTypeAccount->Id->Othr;
36
        $otherAccount = new DTO\OtherAccount((string) $xmlOtherIdentification->Id);
37
38
        if (isset($xmlOtherIdentification->SchmeNm)) {
39
            if (isset($xmlOtherIdentification->SchmeNm->Cd)) {
40
                $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Cd);
41
            }
42
43
            if (isset($xmlOtherIdentification->SchmeNm->Prtry)) {
44
                $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Prtry);
45
            }
46
        }
47
48
        if (isset($xmlOtherIdentification->Issr)) {
49
            $otherAccount->setIssuer((string) $xmlOtherIdentification->Issr);
50
        }
51
52
        return $otherAccount;
53
    }
54
}
55