Conditions | 4 |
Paths | 4 |
Total Lines | 71 |
Code Lines | 52 |
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 |
||
71 | public function findPickupPoints( |
||
72 | string $city, |
||
73 | string $zipCode, |
||
74 | string $countryCode, |
||
75 | string $shippingDate, |
||
76 | array $options = [] |
||
77 | ) { |
||
78 | $params = array_merge( |
||
79 | [ |
||
80 | 'city' => $city, |
||
81 | 'zipCode' => $zipCode, |
||
82 | 'countryCode' => $countryCode, |
||
83 | 'shippingDate' => $shippingDate, |
||
84 | ], |
||
85 | $options |
||
86 | ); |
||
87 | |||
88 | $response = $this->httpRequest( |
||
89 | 'findRDVPointRetraitAcheminement', |
||
90 | $params |
||
91 | ); |
||
92 | |||
93 | $xml = new SimpleXMLElement((string) $response->getBody()); |
||
94 | |||
95 | $return = $xml->xpath('//return'); |
||
96 | if (count($return) && $return[0]->errorCode != 0) { |
||
97 | $this->parseErrorCodeAndThrow((int) $return[0]->errorCode, self::ERRORS); |
||
98 | } |
||
99 | |||
100 | $pickupPoints = []; |
||
101 | foreach ($xml->xpath('//listePointRetraitAcheminement') as $pickupPoint) { |
||
102 | $pickupPoints[] = new PickupPoint( |
||
103 | $pickupPoint->accesPersonneMobiliteReduite, |
||
104 | $pickupPoint->adresse1, |
||
105 | $pickupPoint->adresse2, |
||
106 | $pickupPoint->adresse3, |
||
107 | $pickupPoint->codePostal, |
||
108 | $pickupPoint->congesPartiel, |
||
109 | $pickupPoint->congesTotal, |
||
110 | $pickupPoint->coordGeolocalisationLatitude, |
||
111 | $pickupPoint->coordGeolocalisationLongitude, |
||
112 | $pickupPoint->distanceEnMetre, |
||
113 | $pickupPoint->horairesOuvertureLundi, |
||
114 | $pickupPoint->horairesOuvertureMardi, |
||
115 | $pickupPoint->horairesOuvertureMercredi, |
||
116 | $pickupPoint->horairesOuvertureJeudi, |
||
117 | $pickupPoint->horairesOuvertureVendredi, |
||
118 | $pickupPoint->horairesOuvertureSamedi, |
||
119 | $pickupPoint->horairesOuvertureDimanche, |
||
120 | $pickupPoint->identifiant, |
||
121 | $pickupPoint->indiceDeLocalisation, |
||
122 | $pickupPoint->listeConges, |
||
123 | $pickupPoint->localite, |
||
124 | $pickupPoint->nom, |
||
125 | $pickupPoint->periodeActiviteHoraireDeb, |
||
126 | $pickupPoint->periodeActiviteHoraireFin, |
||
127 | $pickupPoint->poidsMaxi, |
||
128 | $pickupPoint->typeDePoint, |
||
129 | $pickupPoint->codePays, |
||
130 | $pickupPoint->langue, |
||
131 | $pickupPoint->libellePays, |
||
132 | $pickupPoint->loanOfHandlingTool, |
||
133 | $pickupPoint->parking, |
||
134 | $pickupPoint->reseau, |
||
135 | $pickupPoint->distributionSort, |
||
136 | $pickupPoint->lotAcheminement, |
||
137 | $pickupPoint->versionPlanTri |
||
138 | ); |
||
139 | } |
||
140 | |||
141 | return $pickupPoints; |
||
142 | } |
||
221 |