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