| Conditions | 10 |
| Paths | 14 |
| Total Lines | 36 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 42.0294 |
| 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 | 12 | public function getRelatedPartyAccount(?SimpleXMLElement $xmlRelatedPartyTypeAccount): ?DTO\Account |
|
| 16 | { |
||
| 17 | 12 | if (!$xmlRelatedPartyTypeAccount) { |
|
| 18 | 5 | return null; |
|
| 19 | } |
||
| 20 | |||
| 21 | 12 | if (false === isset($xmlRelatedPartyTypeAccount->Id)) { |
|
| 22 | return null; |
||
| 23 | } |
||
| 24 | |||
| 25 | 12 | if (isset($xmlRelatedPartyTypeAccount->Id->IBAN) && $ibanCode = (string) $xmlRelatedPartyTypeAccount->Id->IBAN) { |
|
| 26 | 12 | return new DTO\IbanAccount(new Iban($ibanCode)); |
|
| 27 | } |
||
| 28 | |||
| 29 | if (false === isset($xmlRelatedPartyTypeAccount->Id->Othr)) { |
||
| 30 | return null; |
||
| 31 | } |
||
| 32 | |||
| 33 | $xmlOtherIdentification = $xmlRelatedPartyTypeAccount->Id->Othr; |
||
| 34 | $otherAccount = new DTO\OtherAccount((string) $xmlOtherIdentification->Id); |
||
| 35 | |||
| 36 | if (isset($xmlOtherIdentification->SchmeNm)) { |
||
| 37 | if (isset($xmlOtherIdentification->SchmeNm->Cd)) { |
||
| 38 | $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Cd); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (isset($xmlOtherIdentification->SchmeNm->Prtry)) { |
||
| 42 | $otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Prtry); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | if (isset($xmlOtherIdentification->Issr)) { |
||
| 47 | $otherAccount->setIssuer((string) $xmlOtherIdentification->Issr); |
||
| 48 | } |
||
| 49 | |||
| 50 | return $otherAccount; |
||
| 51 | } |
||
| 53 |