Conditions | 1 |
Paths | 1 |
Total Lines | 98 |
Code Lines | 71 |
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 |
||
169 | public function options( ServerRequestInterface $request, ResponseInterface $response ) |
||
170 | { |
||
171 | $view = $this->getView(); |
||
172 | |||
173 | $view->attributes = [ |
||
174 | 'order.address.salutation' => [ |
||
175 | 'label' => 'Customer salutation, i.e. "comany" ,"mr", "mrs", "miss" or ""', |
||
176 | 'type' => 'string', 'default' => '', 'required' => false, |
||
177 | ], |
||
178 | 'order.address.company' => [ |
||
179 | 'label' => 'Company name', |
||
180 | 'type' => 'string', 'default' => '', 'required' => false, |
||
181 | ], |
||
182 | 'order.address.vatid' => [ |
||
183 | 'label' => 'VAT ID of the company', |
||
184 | 'type' => 'string', 'default' => '', 'required' => false, |
||
185 | ], |
||
186 | 'order.address.title' => [ |
||
187 | 'label' => 'Title of the customer', |
||
188 | 'type' => 'string', 'default' => '', 'required' => false, |
||
189 | ], |
||
190 | 'order.address.firstname' => [ |
||
191 | 'label' => 'First name of the customer', |
||
192 | 'type' => 'string', 'default' => '', 'required' => false, |
||
193 | ], |
||
194 | 'order.address.lastname' => [ |
||
195 | 'label' => 'Last name of the customer or full name', |
||
196 | 'type' => 'string', 'default' => '', 'required' => true, |
||
197 | ], |
||
198 | 'order.address.address1' => [ |
||
199 | 'label' => 'First address part like street', |
||
200 | 'type' => 'string', 'default' => '', 'required' => true, |
||
201 | ], |
||
202 | 'order.address.address2' => [ |
||
203 | 'label' => 'Second address part like house number', |
||
204 | 'type' => 'string', 'default' => '', 'required' => false, |
||
205 | ], |
||
206 | 'order.address.address3' => [ |
||
207 | 'label' => 'Third address part like flat number', |
||
208 | 'type' => 'string', 'default' => '', 'required' => false, |
||
209 | ], |
||
210 | 'order.address.postal' => [ |
||
211 | 'label' => 'Zip code of the city', |
||
212 | 'type' => 'string', 'default' => '', 'required' => false, |
||
213 | ], |
||
214 | 'order.address.city' => [ |
||
215 | 'label' => 'Name of the town/city', |
||
216 | 'type' => 'string', 'default' => '', 'required' => true, |
||
217 | ], |
||
218 | 'order.address.state' => [ |
||
219 | 'label' => 'Two letter code of the country state', |
||
220 | 'type' => 'string', 'default' => '', 'required' => false, |
||
221 | ], |
||
222 | 'order.address.countryid' => [ |
||
223 | 'label' => 'Two letter ISO country code', |
||
224 | 'type' => 'string', 'default' => '', 'required' => true, |
||
225 | ], |
||
226 | 'order.address.languageid' => [ |
||
227 | 'label' => 'Two or five letter ISO language code, e.g. "de" or "de_CH"', |
||
228 | 'type' => 'string', 'default' => '', 'required' => false, |
||
229 | ], |
||
230 | 'order.address.telephone' => [ |
||
231 | 'label' => 'Telephone number consisting of option leading "+" and digits without spaces', |
||
232 | 'type' => 'string', 'default' => '', 'required' => false, |
||
233 | ], |
||
234 | 'order.address.telefax' => [ |
||
235 | 'label' => 'Faximile number consisting of option leading "+" and digits without spaces', |
||
236 | 'type' => 'string', 'default' => '', 'required' => false, |
||
237 | ], |
||
238 | 'order.address.email' => [ |
||
239 | 'label' => 'E-mail address', |
||
240 | 'type' => 'string', 'default' => '', 'required' => false, |
||
241 | ], |
||
242 | 'order.address.website' => [ |
||
243 | 'label' => 'Web site including "http://" or "https://"', |
||
244 | 'type' => 'string', 'default' => '', 'required' => false, |
||
245 | ], |
||
246 | 'order.address.longitude' => [ |
||
247 | 'label' => 'Longitude of the customer location as float value', |
||
248 | 'type' => 'float', 'default' => '', 'required' => false, |
||
249 | ], |
||
250 | 'order.address.latitude' => [ |
||
251 | 'label' => 'Latitude of the customer location as float value', |
||
252 | 'type' => 'float', 'default' => '', 'required' => false, |
||
253 | ], |
||
254 | ]; |
||
255 | |||
256 | $tplconf = 'client/jsonapi/standard/template-options'; |
||
257 | $default = 'options-standard.php'; |
||
258 | |||
259 | $body = $view->render( $view->config( $tplconf, $default ) ); |
||
260 | |||
261 | return $response->withHeader( 'Allow', 'DELETE,GET,OPTIONS,PATCH,POST' ) |
||
262 | ->withHeader( 'Cache-Control', 'max-age=300' ) |
||
263 | ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
||
264 | ->withBody( $view->response()->createStreamFromString( $body ) ) |
||
265 | ->withStatus( 200 ); |
||
266 | } |
||
267 | |||
291 |