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