| Conditions | 1 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 56 |
| 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 |
||
| 86 | public static function provideDataForRetrievingGeodata() |
||
| 87 | { |
||
| 88 | $testdata = [ |
||
| 89 | 'Response with data' => [ |
||
| 90 | '74.200.247.59', |
||
| 91 | '{"city":{"geoname_id":2911298,"names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg","ja":"\u30cf\u30f3\u30d6\u30eb\u30af","pt-BR":"Hamburgo","ru":"\u0413\u0430\u043c\u0431\u0443\u0440\u0433","zh-CN":"\u6c49\u5821\u5e02"}},"continent":{"code":"EU","geoname_id":6255148,"names":{"de":"Europa","en":"Europe","es":"Europa","fr":"Europe","ja":"\u30e8\u30fc\u30ed\u30c3\u30d1","pt-BR":"Europa","ru":"\u0415\u0432\u0440\u043e\u043f\u0430","zh-CN":"\u6b27\u6d32"}},"country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"location":{"latitude":53.55,"longitude":10,"time_zone":"Europe\/Berlin"},"registered_country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"subdivisions":[{"geoname_id":2911297,"iso_code":"HH","names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg"}}],"traits":{"ip_address":"74.200.247.59"},"postal":{"code":"EC4N"}}', |
||
| 92 | [ |
||
| 93 | 'latitude' => 53.55, |
||
| 94 | 'longitude' => 10, |
||
| 95 | 'boundsDefined' => null, |
||
| 96 | 'streetNumber' => null, |
||
| 97 | 'streetName' => null, |
||
| 98 | 'locality' => 'Hamburg', |
||
| 99 | 'subLocality' => null, |
||
| 100 | 'postalCode' => 'EC4N', |
||
| 101 | 'adminLevels' => [1 => [ |
||
| 102 | 'name' => 'Hamburg', |
||
| 103 | 'code' => 'HH', |
||
| 104 | ]], |
||
| 105 | 'country' => 'Germany', |
||
| 106 | 'countryCode' => 'DE', |
||
| 107 | 'timezone' => 'Europe/Berlin', |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | 'Response with all possible data' => [ |
||
| 111 | '93.36.20.217', |
||
| 112 | '{"country": {"iso_code": "IT","names": {"pt-BR": "Itália","es": "Italia","ru": "Италия","en": "Italy","zh-CN": "意大利","fr": "Italie","de": "Italien","ja": "イタリア共和国"},"geoname_id": 3175395},"location": {"longitude": 9.2667,"latitude": 45.5833,"time_zone": "Europe/Rome"},"subdivisions": [{"iso_code": "25","names": {"en": "Lombardy","fr": "Lombardie","de": "Lombardei","es": "Lombardía"},"geoname_id": 3174618},{"iso_code": "MB","names": {"en": "Monza Brianza"},"geoname_id": 6955700}],"postal": {"code": "20900"},"city": {"names": {"pt-BR": "Monza","es": "Monza","ru": "Монца","en": "Monza","zh-CN": "蒙扎","fr": "Monza","de": "Monza","ja": "モンツァ"},"geoname_id": 3172629},"continent": {"names": {"pt-BR": "Europa","es": "Europa","ru": "Европа","en": "Europe","zh-CN": "欧洲","fr": "Europe","de": "Europa","ja": "ヨーロッパ"},"geoname_id": 6255148,"code": "EU"},"registered_country": {"iso_code": "IT","names": {"pt-BR": "Itália","es": "Italia","ru": "Италия","en": "Italy","zh-CN": "意大利","fr": "Italie","de": "Italien","ja": "イタリア共和国"},"geoname_id": 3175395},"traits": {"domain": "fastwebnet.it","autonomous_system_number": 12874,"ip_address": "93.36.20.217","organization": "Fastweb","isp": "Fastweb","autonomous_system_organization": "Fastweb SpA"},"represented_country": {"names": {}}}', |
||
| 113 | [ |
||
| 114 | 'latitude' => 45.5833, |
||
| 115 | 'longitude' => 9.2667, |
||
| 116 | 'boundsDefined' => null, |
||
| 117 | 'streetNumber' => null, |
||
| 118 | 'streetName' => null, |
||
| 119 | 'locality' => 'Monza', |
||
| 120 | 'subLocality' => null, |
||
| 121 | 'postalCode' => '20900', |
||
| 122 | 'adminLevels' => [ |
||
| 123 | 1 => [ |
||
| 124 | 'name' => 'Lombardy', |
||
| 125 | 'code' => '25', |
||
| 126 | ], |
||
| 127 | 2 => [ |
||
| 128 | 'name' => 'Monza Brianza', |
||
| 129 | 'code' => 'MB', |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | 'country' => 'Italy', |
||
| 133 | 'countryCode' => 'IT', |
||
| 134 | 'timezone' => 'Europe/Rome', |
||
| 135 | ], |
||
| 136 | ], |
||
| 137 | 'Response with all data null' => [ |
||
| 138 | '74.200.247.59', |
||
| 139 | '{}', |
||
| 140 | [ |
||
| 141 | 'latitude' => null, |
||
| 142 | 'longitude' => null, |
||
| 143 | 'boundsDefined' => null, |
||
| 144 | 'streetNumber' => null, |
||
| 145 | 'streetName' => null, |
||
| 146 | 'locality' => null, |
||
| 147 | 'subLocality' => null, |
||
| 148 | 'postalCode' => null, |
||
| 149 | 'adminLevels' => [], |
||
| 150 | 'country' => null, |
||
| 151 | 'countryCode' => null, |
||
| 152 | 'timezone' => null, |
||
| 153 | ], |
||
| 154 | ], |
||
| 155 | ]; |
||
| 156 | |||
| 157 | return $testdata; |
||
| 158 | } |
||
| 159 | |||
| 249 |