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

EntryTransactionDetail   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 52
ccs 14
cts 24
cp 0.5833
rs 10

1 Method

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