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

EntryTransactionDetail::getRelatedPartyAccount()   C

Complexity

Conditions 12
Paths 17

Size

Total Lines 47
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 72.75

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 47
ccs 6
cts 24
cp 0.25
rs 5.1384
cc 12
eloc 23
nc 17
nop 1
crap 72.75

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