Conditions | 12 |
Paths | 17 |
Total Lines | 48 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 24.2664 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 | 7 | public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAccount): ?DTO\Account |
|
16 | { |
||
17 | 7 | if (!$xmlRelatedPartyTypeAccount) { |
|
18 | return null; |
||
19 | } |
||
20 | |||
21 | 7 | if (false === isset($xmlRelatedPartyTypeAccount->Id)) { |
|
22 | return null; |
||
23 | } |
||
24 | |||
25 | 7 | if (isset($xmlRelatedPartyTypeAccount->Id->IBAN)) { |
|
26 | 6 | return new DTO\IbanAccount(new Iban((string) $xmlRelatedPartyTypeAccount->Id->IBAN)); |
|
27 | } |
||
28 | |||
29 | 1 | if (isset($xmlRelatedPartyTypeAccount->Id->BBAN)) { |
|
30 | return new DTO\BBANAccount((string) $xmlRelatedPartyTypeAccount->Id->BBAN); |
||
31 | } |
||
32 | |||
33 | 1 | if (isset($xmlRelatedPartyTypeAccount->Id->UPIC)) { |
|
34 | return new DTO\UPICAccount((string) $xmlRelatedPartyTypeAccount->Id->UPIC); |
||
35 | } |
||
36 | |||
37 | 1 | if (isset($xmlRelatedPartyTypeAccount->Id->PrtryAcct)) { |
|
38 | return new DTO\ProprietaryAccount((string) $xmlRelatedPartyTypeAccount->Id->PrtryAcct->Id); |
||
39 | } |
||
40 | |||
41 | 1 | if (isset($xmlRelatedPartyTypeAccount->Id->Othr)) { |
|
42 | 1 | $xmlOtherIdentification = $xmlRelatedPartyTypeAccount->Id->Othr; |
|
43 | 1 | $otherAccount = new DTO\OtherAccount((string) $xmlOtherIdentification->Id); |
|
44 | |||
45 | 1 | if (isset($xmlOtherIdentification->SchmeNm)) { |
|
46 | if (isset($xmlOtherIdentification->SchmeNm->Cd)) { |
||
47 | $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Cd); |
||
48 | } |
||
49 | |||
50 | if (isset($xmlOtherIdentification->SchmeNm->Prtry)) { |
||
51 | $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Prtry); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | 1 | if (isset($xmlOtherIdentification->Issr)) { |
|
56 | $otherAccount->setIssuer($xmlOtherIdentification->Issr); |
||
57 | } |
||
58 | |||
59 | 1 | return $otherAccount; |
|
60 | } |
||
61 | |||
62 | return null; |
||
63 | } |
||
65 |