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

EntryTransactionDetail::getRelatedPartyAccount()   C

Complexity

Conditions 12
Paths 17

Size

Total Lines 46
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 22.4191

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 46
ccs 14
cts 24
cp 0.5833
rs 5.15
cc 12
eloc 23
nc 17
nop 1
crap 22.4191

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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