| Conditions | 11 | 
| Paths | 512 | 
| Total Lines | 36 | 
| Code Lines | 22 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 19 | 
| CRAP Score | 11.307 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
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 | 17 | public static function createFromXml(SimpleXMLElement $xmlAddress)  | 
            |
| 16 |     { | 
            ||
| 17 | 17 | $address = new DTO\Address();  | 
            |
| 18 | |||
| 19 | 17 |         if (isset($xmlAddress->Ctry)) { | 
            |
| 20 | 17 | $address = $address->setCountry((string) $xmlAddress->Ctry);  | 
            |
| 21 | }  | 
            ||
| 22 | 17 |         if (isset($xmlAddress->CtrySubDvsn)) { | 
            |
| 23 | $address = $address->setCountrySubDivision((string) $xmlAddress->CtrySubDvsn);  | 
            ||
| 24 | }  | 
            ||
| 25 | 17 |         if (isset($xmlAddress->Dept)) { | 
            |
| 26 | $address = $address->setDepartment((string) $xmlAddress->Dept);  | 
            ||
| 27 | }  | 
            ||
| 28 | 17 |         if (isset($xmlAddress->SubDept)) { | 
            |
| 29 | $address = $address->setSubDepartment((string) $xmlAddress->SubDept);  | 
            ||
| 30 | }  | 
            ||
| 31 | 17 |         if (isset($xmlAddress->StrtNm)) { | 
            |
| 32 | 16 | $address = $address->setStreetName((string) $xmlAddress->StrtNm);  | 
            |
| 33 | }  | 
            ||
| 34 | 17 |         if (isset($xmlAddress->BldgNb)) { | 
            |
| 35 | 3 | $address = $address->setBuildingNumber((string) $xmlAddress->BldgNb);  | 
            |
| 36 | }  | 
            ||
| 37 | 17 |         if (isset($xmlAddress->PstCd)) { | 
            |
| 38 | 3 | $address = $address->setPostCode((string) $xmlAddress->PstCd);  | 
            |
| 39 | }  | 
            ||
| 40 | 17 |         if (isset($xmlAddress->TwnNm)) { | 
            |
| 41 | 3 | $address = $address->setTownName((string) $xmlAddress->TwnNm);  | 
            |
| 42 | }  | 
            ||
| 43 | 17 |         if (isset($xmlAddress->AdrLine)) { | 
            |
| 44 | 1 |             foreach ($xmlAddress->AdrLine as $line) { | 
            |
| 45 | 1 | $address = $address->addAddressLine((string)$line);  | 
            |
| 46 | }  | 
            ||
| 47 | }  | 
            ||
| 48 | |||
| 49 | 17 | return $address;  | 
            |
| 50 | }  | 
            ||
| 51 | }  | 
            ||
| 52 |