| Conditions | 5 |
| Paths | 4 |
| Total Lines | 64 |
| Code Lines | 50 |
| 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 |
||
| 155 | public function findPickupPointByID(int $id, string $shippingDate, array $options = []) |
||
| 156 | { |
||
| 157 | $options = array_merge( |
||
| 158 | [ |
||
| 159 | 'id' => $id, |
||
| 160 | 'date' => $shippingDate, |
||
| 161 | ], |
||
| 162 | $options |
||
| 163 | ); |
||
| 164 | |||
| 165 | $response = $this->httpRequest( |
||
| 166 | 'findPointRetraitAcheminementByID', |
||
| 167 | $options |
||
| 168 | ); |
||
| 169 | |||
| 170 | $xml = new SimpleXMLElement((string) $response->getBody()); |
||
| 171 | |||
| 172 | $return = $xml->xpath('//return'); |
||
| 173 | if (count($return) && $return[0]->errorCode != 0) { |
||
| 174 | $this->parseErrorCodeAndThrow((int) $return[0]->errorCode, self::ERRORS); |
||
| 175 | } |
||
| 176 | |||
| 177 | $rawPickupPoint = $xml->xpath('//pointRetraitAcheminement'); |
||
| 178 | if (count($rawPickupPoint) && $rawPickupPoint[0]) { |
||
| 179 | $pickupPoint = new PickupPoint( |
||
| 180 | $rawPickupPoint[0]->accesPersonneMobiliteReduite, |
||
| 181 | $rawPickupPoint[0]->adresse1, |
||
| 182 | $rawPickupPoint[0]->adresse2, |
||
| 183 | $rawPickupPoint[0]->adresse3, |
||
| 184 | $rawPickupPoint[0]->codePostal, |
||
| 185 | $rawPickupPoint[0]->congesPartiel, |
||
| 186 | $rawPickupPoint[0]->congesTotal, |
||
| 187 | $rawPickupPoint[0]->coordGeolocalisationLatitude, |
||
| 188 | $rawPickupPoint[0]->coordGeolocalisationLongitude, |
||
| 189 | $rawPickupPoint[0]->distanceEnMetre, |
||
| 190 | $rawPickupPoint[0]->horairesOuvertureLundi, |
||
| 191 | $rawPickupPoint[0]->horairesOuvertureMardi, |
||
| 192 | $rawPickupPoint[0]->horairesOuvertureMercredi, |
||
| 193 | $rawPickupPoint[0]->horairesOuvertureJeudi, |
||
| 194 | $rawPickupPoint[0]->horairesOuvertureVendredi, |
||
| 195 | $rawPickupPoint[0]->horairesOuvertureSamedi, |
||
| 196 | $rawPickupPoint[0]->horairesOuvertureDimanche, |
||
| 197 | $rawPickupPoint[0]->identifiant, |
||
| 198 | $rawPickupPoint[0]->indiceDeLocalisation, |
||
| 199 | $rawPickupPoint[0]->listeConges, |
||
| 200 | $rawPickupPoint[0]->localite, |
||
| 201 | $rawPickupPoint[0]->nom, |
||
| 202 | $rawPickupPoint[0]->periodeActiviteHoraireDeb, |
||
| 203 | $rawPickupPoint[0]->periodeActiviteHoraireFin, |
||
| 204 | $rawPickupPoint[0]->poidsMaxi, |
||
| 205 | $rawPickupPoint[0]->typeDePoint, |
||
| 206 | $rawPickupPoint[0]->codePays, |
||
| 207 | $rawPickupPoint[0]->langue, |
||
| 208 | $rawPickupPoint[0]->libellePays, |
||
| 209 | $rawPickupPoint[0]->loanOfHandlingTool, |
||
| 210 | $rawPickupPoint[0]->parking, |
||
| 211 | $rawPickupPoint[0]->reseau, |
||
| 212 | $rawPickupPoint[0]->distributionSort, |
||
| 213 | $rawPickupPoint[0]->lotAcheminement, |
||
| 214 | $rawPickupPoint[0]->versionPlanTri |
||
| 215 | ); |
||
| 216 | } |
||
| 217 | |||
| 218 | return $pickupPoint; |
||
|
|
|||
| 219 | } |
||
| 221 |