| 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 |
||
| 204 | public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
||
| 205 | { |
||
| 206 | $view = $this->getView(); |
||
| 207 | $view->attributes = [ |
||
| 208 | 'customer.salutation' => [ |
||
| 209 | 'label' => 'Customer salutation, i.e. "comany" ,"mr", "mrs", "miss" or ""', |
||
| 210 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 211 | ], |
||
| 212 | 'customer.company' => [ |
||
| 213 | 'label' => 'Company name', |
||
| 214 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 215 | ], |
||
| 216 | 'customer.vatid' => [ |
||
| 217 | 'label' => 'VAT ID of the company', |
||
| 218 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 219 | ], |
||
| 220 | 'customer.title' => [ |
||
| 221 | 'label' => 'Title of the customer', |
||
| 222 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 223 | ], |
||
| 224 | 'customer.firstname' => [ |
||
| 225 | 'label' => 'First name of the customer', |
||
| 226 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 227 | ], |
||
| 228 | 'customer.lastname' => [ |
||
| 229 | 'label' => 'Last name of the customer or full name', |
||
| 230 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 231 | ], |
||
| 232 | 'customer.address1' => [ |
||
| 233 | 'label' => 'First address part like street', |
||
| 234 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 235 | ], |
||
| 236 | 'customer.address2' => [ |
||
| 237 | 'label' => 'Second address part like house number', |
||
| 238 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 239 | ], |
||
| 240 | 'customer.address3' => [ |
||
| 241 | 'label' => 'Third address part like flat number', |
||
| 242 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 243 | ], |
||
| 244 | 'customer.postal' => [ |
||
| 245 | 'label' => 'Zip code of the city', |
||
| 246 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 247 | ], |
||
| 248 | 'customer.city' => [ |
||
| 249 | 'label' => 'Name of the town/city', |
||
| 250 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 251 | ], |
||
| 252 | 'customer.state' => [ |
||
| 253 | 'label' => 'Two letter code of the country state', |
||
| 254 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 255 | ], |
||
| 256 | 'customer.countryid' => [ |
||
| 257 | 'label' => 'Two letter ISO country code', |
||
| 258 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 259 | ], |
||
| 260 | 'customer.languageid' => [ |
||
| 261 | 'label' => 'Two or five letter ISO language code, e.g. "de" or "de_CH"', |
||
| 262 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 263 | ], |
||
| 264 | 'customer.telephone' => [ |
||
| 265 | 'label' => 'Telephone number consisting of option leading "+" and digits without spaces', |
||
| 266 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 267 | ], |
||
| 268 | 'customer.telefax' => [ |
||
| 269 | 'label' => 'Faximile number consisting of option leading "+" and digits without spaces', |
||
| 270 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 271 | ], |
||
| 272 | 'customer.email' => [ |
||
| 273 | 'label' => 'E-mail address', |
||
| 274 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 275 | ], |
||
| 276 | 'customer.website' => [ |
||
| 277 | 'label' => 'Web site including "http://" or "https://"', |
||
| 278 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 279 | ], |
||
| 280 | 'customer.longitude' => [ |
||
| 281 | 'label' => 'Longitude of the customer location as float value', |
||
| 282 | 'type' => 'float', 'default' => '', 'required' => false, |
||
| 283 | ], |
||
| 284 | 'customer.latitude' => [ |
||
| 285 | 'label' => 'Latitude of the customer location as float value', |
||
| 286 | 'type' => 'float', 'default' => '', 'required' => false, |
||
| 287 | ], |
||
| 288 | 'customer.label' => [ |
||
| 289 | 'label' => 'Label to identify the customer, usually the full name', |
||
| 290 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 291 | ], |
||
| 292 | 'customer.code' => [ |
||
| 293 | 'label' => 'Unique customer identifier, usually e-mail address', |
||
| 294 | 'type' => 'string', 'default' => '', 'required' => true, |
||
| 295 | ], |
||
| 296 | 'customer.birthday' => [ |
||
| 297 | 'label' => 'ISO date in YYYY-MM-DD format of the birthday', |
||
| 298 | 'type' => 'string', 'default' => '', 'required' => false, |
||
| 299 | ], |
||
| 300 | 'customer.status' => [ |
||
| 301 | 'label' => 'Customer account status, i.e. "0" for disabled, "1" for enabled', |
||
| 302 | 'type' => 'integer', 'default' => '1', 'required' => false, |
||
| 303 | ], |
||
| 304 | ]; |
||
| 305 | |||
| 306 | $tplconf = 'client/jsonapi/standard/template-options'; |
||
| 307 | $default = 'options-standard.php'; |
||
| 308 | |||
| 309 | $body = $view->render( $view->config( $tplconf, $default ) ); |
||
| 310 | |||
| 311 | return $response->withHeader( 'Allow', 'DELETE,GET,OPTIONS,PATCH,POST' ) |
||
| 312 | ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
||
| 313 | ->withBody( $view->response()->createStreamFromString( $body ) ) |
||
| 314 | ->withStatus( 200 ); |
||
| 315 | } |
||
| 316 | |||
| 358 |