Completed
Pull Request — master (#32)
by
unknown
04:50
created

EntryTransactionDetail::getRelatedPartyAccount()   C

Complexity

Conditions 11
Paths 16

Size

Total Lines 43
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 20.9461

Importance

Changes 3
Bugs 1 Features 3
Metric Value
c 3
b 1
f 3
dl 0
loc 43
ccs 13
cts 23
cp 0.5652
rs 5.2653
cc 11
eloc 22
nc 16
nop 1
crap 20.9461

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