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