| Conditions | 1 |
| Paths | 1 |
| Total Lines | 112 |
| Code Lines | 82 |
| 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 |
||
| 264 | public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
||
| 265 | { |
||
| 266 | $view = $this->getView(); |
||
| 267 | $view->attributes = [ |
||
| 268 | 'customer.address.salutation' => [ |
||
| 269 | 'label' => 'Customer salutation, i.e. "comany" ,"mr", "mrs", "miss" or ""', |
||
| 270 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 271 | ], |
||
| 272 | 'customer.address.company' => [ |
||
| 273 | 'label' => 'Company name', |
||
| 274 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 275 | ], |
||
| 276 | 'customer.address.vatid' => [ |
||
| 277 | 'label' => 'VAT ID of the company', |
||
| 278 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 279 | ], |
||
| 280 | 'customer.address.title' => [ |
||
| 281 | 'label' => 'Title of the customer', |
||
| 282 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 283 | ], |
||
| 284 | 'customer.address.firstname' => [ |
||
| 285 | 'label' => 'First name of the customer', |
||
| 286 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 287 | ], |
||
| 288 | 'customer.address.lastname' => [ |
||
| 289 | 'label' => 'Last name of the customer or full name', |
||
| 290 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 291 | ], |
||
| 292 | 'customer.address.address1' => [ |
||
| 293 | 'label' => 'First address part like street', |
||
| 294 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 295 | ], |
||
| 296 | 'customer.address.address2' => [ |
||
| 297 | 'label' => 'Second address part like house number', |
||
| 298 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 299 | ], |
||
| 300 | 'customer.address.address3' => [ |
||
| 301 | 'label' => 'Third address part like flat number', |
||
| 302 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 303 | ], |
||
| 304 | 'customer.address.postal' => [ |
||
| 305 | 'label' => 'Zip code of the city', |
||
| 306 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 307 | ], |
||
| 308 | 'customer.address.city' => [ |
||
| 309 | 'label' => 'Name of the town/city', |
||
| 310 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 311 | ], |
||
| 312 | 'customer.address.state' => [ |
||
| 313 | 'label' => 'Two letter code of the country state', |
||
| 314 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 315 | ], |
||
| 316 | 'customer.address.countryid' => [ |
||
| 317 | 'label' => 'Two letter ISO country code', |
||
| 318 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 319 | ], |
||
| 320 | 'customer.address.languageid' => [ |
||
| 321 | 'label' => 'Two or five letter ISO language code, e.g. "de" or "de_CH"', |
||
| 322 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 323 | ], |
||
| 324 | 'customer.address.telephone' => [ |
||
| 325 | 'label' => 'Telephone number consisting of option leading "+" and digits without spaces', |
||
| 326 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 327 | ], |
||
| 328 | 'customer.address.telefax' => [ |
||
| 329 | 'label' => 'Faximile number consisting of option leading "+" and digits without spaces', |
||
| 330 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 331 | ], |
||
| 332 | 'customer.address.email' => [ |
||
| 333 | 'label' => 'E-mail address', |
||
| 334 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 335 | ], |
||
| 336 | 'customer.address.website' => [ |
||
| 337 | 'label' => 'Web site including "http://" or "https://"', |
||
| 338 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 339 | ], |
||
| 340 | 'customer.address.longitude' => [ |
||
| 341 | 'label' => 'Longitude of the customer location as float value', |
||
| 342 | 'type' => 'float', 'default' => '', 'required' => false, |
||
| 343 | ], |
||
| 344 | 'customer.address.latitude' => [ |
||
| 345 | 'label' => 'Latitude of the customer location as float value', |
||
| 346 | 'type' => 'float', 'default' => '', 'required' => false, |
||
| 347 | ], |
||
| 348 | 'customer.address.label' => [ |
||
| 349 | 'label' => 'Label to identify the customer, usually the full name', |
||
| 350 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 351 | ], |
||
| 352 | 'customer.address.code' => [ |
||
| 353 | 'label' => 'Unique customer identifier, usually e-mail address', |
||
| 354 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 355 | ], |
||
| 356 | 'customer.address.birthday' => [ |
||
| 357 | 'label' => 'ISO date in YYYY-MM-DD format of the birthday', |
||
| 358 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 359 | ], |
||
| 360 | 'customer.address.status' => [ |
||
| 361 | 'label' => 'Customer account status, i.e. "0" for disabled, "1" for enabled', |
||
| 362 | 'type' => 'integer', 'default' => '1', 'required' => false, |
||
| 363 | ], |
||
| 364 | ]; |
||
| 365 | |||
| 366 | $tplconf = 'client/jsonapi/standard/template-options'; |
||
| 367 | $default = 'options-standard.php'; |
||
| 368 | |||
| 369 | $body = $view->render( $view->config( $tplconf, $default ) ); |
||
| 370 | |||
| 371 | return $response->withHeader( 'Allow', 'DELETE,GET,OPTIONS,PATCH,POST' ) |
||
| 372 | ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
||
| 373 | ->withBody( $view->response()->createStreamFromString( $body ) ) |
||
| 374 | ->withStatus( 200 ); |
||
| 375 | } |
||
| 376 | |||
| 399 |