| Conditions | 1 |
| Paths | 1 |
| Total Lines | 117 |
| Code Lines | 76 |
| 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 |
||
| 51 | public function setUp() { |
||
| 52 | |||
| 53 | // This is the sample value from Google Maps official documentation |
||
| 54 | $default_response_OK = [ |
||
| 55 | 'results' => [ |
||
| 56 | 0 => [ |
||
| 57 | 'address_components' => [ |
||
| 58 | 0 => [ |
||
| 59 | 'long_name' => '277', |
||
| 60 | 'short_name' => '277', |
||
| 61 | 'types' => [ |
||
| 62 | 0 => 'street_number', |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | 1 => [ |
||
| 66 | 'long_name' => 'Bedford Avenue', |
||
| 67 | 'short_name' => 'Bedford Ave', |
||
| 68 | 'types' => [ |
||
| 69 | 0 => 'route', |
||
| 70 | ], |
||
| 71 | ], |
||
| 72 | 2 => [ |
||
| 73 | 'long_name' => 'Williamsburg', |
||
| 74 | 'short_name' => 'Williamsburg', |
||
| 75 | 'types' => [ |
||
| 76 | 0 => 'neighborhood', |
||
| 77 | 1 => 'political', |
||
| 78 | ], |
||
| 79 | ], |
||
| 80 | 3 => [ |
||
| 81 | 'long_name' => 'Brooklyn', |
||
| 82 | 'short_name' => 'Brooklyn', |
||
| 83 | 'types' => [ |
||
| 84 | 0 => 'political', |
||
| 85 | 1 => 'sublocality', |
||
| 86 | 2 => 'sublocality_level_1', |
||
| 87 | ], |
||
| 88 | ], |
||
| 89 | 4 => [ |
||
| 90 | 'long_name' => 'Kings County', |
||
| 91 | 'short_name' => 'Kings County', |
||
| 92 | 'types' => [ |
||
| 93 | 0 => 'administrative_area_level_2', |
||
| 94 | 1 => 'political', |
||
| 95 | ], |
||
| 96 | ], |
||
| 97 | 5 => [ |
||
| 98 | 'long_name' => 'New York', |
||
| 99 | 'short_name' => 'NY', |
||
| 100 | 'types' => [ |
||
| 101 | 0 => 'administrative_area_level_1', |
||
| 102 | 1 => 'political', |
||
| 103 | ], |
||
| 104 | ], |
||
| 105 | 6 => [ |
||
| 106 | 'long_name' => 'United States', |
||
| 107 | 'short_name' => 'US', |
||
| 108 | 'types' => [ |
||
| 109 | 0 => 'country', |
||
| 110 | 1 => 'political', |
||
| 111 | ], |
||
| 112 | ], |
||
| 113 | 7 => [ |
||
| 114 | 'long_name' => '11211', |
||
| 115 | 'short_name' => '11211', |
||
| 116 | 'types' => [ |
||
| 117 | 0 => 'postal_code', |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | ], |
||
| 121 | 'formatted_address' => '277 Bedford Ave, Brooklyn, NY 11211, USA', |
||
| 122 | 'geometry' => [ |
||
| 123 | 'location' => [ |
||
| 124 | 'lat' => 40.71422050000000325553628499619662761688232421875, |
||
| 125 | 'lng' => -73.961290300000001707303454168140888214111328125, |
||
| 126 | ], |
||
| 127 | 'location_type' => 'ROOFTOP', |
||
| 128 | 'viewport' => [ |
||
| 129 | 'northeast' => [ |
||
| 130 | 'lat' => 40.7155694802914922547643072903156280517578125, |
||
| 131 | 'lng' => -73.9599413197084913917933590710163116455078125, |
||
| 132 | ], |
||
| 133 | 'southwest' => [ |
||
| 134 | 'lat' => 40.712871519708500045453547500073909759521484375, |
||
| 135 | 'lng' => -73.9626392802914978119588340632617473602294921875, |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | 'place_id' => 'ChIJd8BlQ2BZwokRAFUEcm_qrcA', |
||
| 140 | 'types' => [ |
||
| 141 | 0 => 'street_address', |
||
| 142 | ], |
||
| 143 | ], |
||
| 144 | ], |
||
| 145 | 'status' => 'OK', |
||
| 146 | ]; |
||
| 147 | |||
| 148 | $default_response_KO = array_merge($default_response_OK, [ |
||
| 149 | 'status' => GoogleMapsResponseStatusValues::REQUEST_DENIED |
||
| 150 | ]); |
||
| 151 | |||
| 152 | // geocoding with API key |
||
| 153 | // Remember to associate a valid payment method to your project |
||
| 154 | $this->geocoding_with_key = new Geocoding([ |
||
| 155 | GoogleMapsApiConfigFields::KEY => 'MyKey' |
||
| 156 | ]); |
||
| 157 | |||
| 158 | // geocoding with sensor |
||
| 159 | $this->geocoding_with_sensor = new Geocoding([ |
||
| 160 | GoogleMapsApiConfigFields::SENSOR => 'true' |
||
| 161 | ]); |
||
| 162 | |||
| 163 | // geocoding with NO API key |
||
| 164 | $this->geocoding_no_key = new Geocoding(); |
||
| 165 | |||
| 166 | $this->mock_response_ok = new Response(200, [], \GuzzleHttp\json_encode($default_response_OK)); |
||
| 167 | $this->mock_response_ko = new Response(200, [], \GuzzleHttp\json_encode($default_response_KO)); |
||
| 168 | } |
||
| 225 |