Conditions | 11 |
Paths | 16 |
Total Lines | 43 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 20.9461 |
Changes | 3 | ||
Bugs | 1 | Features | 3 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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 |