| Conditions | 15 |
| Paths | 990 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 16 | public function __construct($locationArray) |
||
| 17 | { |
||
| 18 | $this->verified = (isset($locationArray['analysis']) && $locationArray['analysis']['verification_status'] && $locationArray['analysis']['verification_status'] == 'Verified') ? true : false; |
||
| 19 | |||
| 20 | if (isset($locationArray['components']) && is_array($locationArray['components'])) { |
||
| 21 | $this->street = isset($locationArray['components']['thoroughfare']) ? $locationArray['components']['thoroughfare'] : ''; |
||
| 22 | $this->streetNumber = isset($locationArray['components']['premise']) ? $locationArray['components']['premise'] : ''; |
||
| 23 | $this->locality = isset($locationArray['components']['locality']) ? $locationArray['components']['locality'] : ''; |
||
| 24 | $this->postcode = isset($locationArray['components']['postal_code']) ? $locationArray['components']['postal_code'] : ''; |
||
| 25 | $this->country = isset($locationArray['components']['country_iso_3']) ? $locationArray['components']['country_iso_3'] : ''; |
||
| 26 | } |
||
| 27 | |||
| 28 | if (isset($locationArray['metadata']) && is_array($locationArray['metadata'])) { |
||
| 29 | $this->latitude = isset($locationArray['metadata']['latitude']) ? $locationArray['metadata']['latitude'] : ''; |
||
| 30 | $this->longitude = isset($locationArray['metadata']['longitude']) ? $locationArray['metadata']['longitude'] : ''; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 74 |