| Conditions | 1 |
| Paths | 1 |
| Total Lines | 197 |
| Code Lines | 126 |
| 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 |
||
| 241 | public static function providerShouldInvoiceInitial(): iterable |
||
| 242 | { |
||
| 243 | yield 'create MANDATORY booking should invoice' => [ |
||
| 244 | [ |
||
| 245 | 'id' => null, |
||
| 246 | 'previousStatus' => null, |
||
| 247 | 'status' => BookingStatus::Booked, |
||
| 248 | 'bookable' => [ |
||
| 249 | 'creditAccount' => true, |
||
| 250 | 'initialPrice' => Money::CHF(100), |
||
| 251 | 'periodicPrice' => Money::CHF(100), |
||
| 252 | 'bookingType' => BookingType::Mandatory, |
||
| 253 | ], |
||
| 254 | ], |
||
| 255 | 1, |
||
| 256 | ]; |
||
| 257 | yield 'update MANDATORY booking should not invoice' => [ |
||
| 258 | [ |
||
| 259 | 'id' => 123, |
||
| 260 | 'previousStatus' => null, |
||
| 261 | 'status' => BookingStatus::Booked, |
||
| 262 | 'bookable' => [ |
||
| 263 | 'creditAccount' => true, |
||
| 264 | 'initialPrice' => Money::CHF(100), |
||
| 265 | 'periodicPrice' => Money::CHF(100), |
||
| 266 | 'bookingType' => BookingType::Mandatory, |
||
| 267 | ], |
||
| 268 | ], |
||
| 269 | 0, |
||
| 270 | ]; |
||
| 271 | yield 'create MANDATORY booking that is processed should invoice' => [ |
||
| 272 | [ |
||
| 273 | 'id' => null, |
||
| 274 | 'previousStatus' => null, |
||
| 275 | 'status' => BookingStatus::Processed, |
||
| 276 | 'bookable' => [ |
||
| 277 | 'creditAccount' => true, |
||
| 278 | 'initialPrice' => Money::CHF(100), |
||
| 279 | 'periodicPrice' => Money::CHF(100), |
||
| 280 | 'bookingType' => BookingType::Mandatory, |
||
| 281 | ], |
||
| 282 | ], |
||
| 283 | 1, |
||
| 284 | ]; |
||
| 285 | yield 'create MANDATORY booking that is application should not invoice' => [ |
||
| 286 | [ |
||
| 287 | 'id' => null, |
||
| 288 | 'previousStatus' => null, |
||
| 289 | 'status' => BookingStatus::Application, |
||
| 290 | 'bookable' => [ |
||
| 291 | 'creditAccount' => true, |
||
| 292 | 'initialPrice' => Money::CHF(100), |
||
| 293 | 'periodicPrice' => Money::CHF(100), |
||
| 294 | 'bookingType' => BookingType::Mandatory, |
||
| 295 | ], |
||
| 296 | ], |
||
| 297 | 0, |
||
| 298 | ]; |
||
| 299 | yield 'create MANDATORY booking without creditAccount should not invoice' => [ |
||
| 300 | [ |
||
| 301 | 'id' => null, |
||
| 302 | 'previousStatus' => null, |
||
| 303 | 'status' => BookingStatus::Booked, |
||
| 304 | 'bookable' => [ |
||
| 305 | 'creditAccount' => false, |
||
| 306 | 'initialPrice' => Money::CHF(100), |
||
| 307 | 'periodicPrice' => Money::CHF(100), |
||
| 308 | 'bookingType' => BookingType::Mandatory, |
||
| 309 | ], |
||
| 310 | ], |
||
| 311 | 0, |
||
| 312 | ]; |
||
| 313 | yield 'create MANDATORY free booking should not invoice' => [ |
||
| 314 | [ |
||
| 315 | 'id' => null, |
||
| 316 | 'previousStatus' => null, |
||
| 317 | 'status' => BookingStatus::Booked, |
||
| 318 | 'bookable' => [ |
||
| 319 | 'creditAccount' => true, |
||
| 320 | 'initialPrice' => Money::CHF(0), |
||
| 321 | 'periodicPrice' => Money::CHF(0), |
||
| 322 | 'bookingType' => BookingType::Mandatory, |
||
| 323 | ], |
||
| 324 | ], |
||
| 325 | 0, |
||
| 326 | ]; |
||
| 327 | yield 'create MANDATORY booking with free initialPrice and non-free periodicPrice should still actually invoice, because we also invoice periodicPrice' => [ |
||
| 328 | [ |
||
| 329 | 'id' => null, |
||
| 330 | 'previousStatus' => null, |
||
| 331 | 'status' => BookingStatus::Booked, |
||
| 332 | 'bookable' => [ |
||
| 333 | 'creditAccount' => true, |
||
| 334 | 'initialPrice' => Money::CHF(0), |
||
| 335 | 'periodicPrice' => Money::CHF(100), |
||
| 336 | 'bookingType' => BookingType::Mandatory, |
||
| 337 | ], |
||
| 338 | ], |
||
| 339 | 1, |
||
| 340 | ]; |
||
| 341 | yield 'create APPLICATION booking should not invoice' => [ |
||
| 342 | [ |
||
| 343 | 'id' => null, |
||
| 344 | 'previousStatus' => null, |
||
| 345 | 'status' => BookingStatus::Booked, |
||
| 346 | 'bookable' => [ |
||
| 347 | 'creditAccount' => true, |
||
| 348 | 'initialPrice' => Money::CHF(100), |
||
| 349 | 'periodicPrice' => Money::CHF(100), |
||
| 350 | 'bookingType' => BookingType::Application, |
||
| 351 | ], |
||
| 352 | ], |
||
| 353 | 0, |
||
| 354 | ]; |
||
| 355 | yield 'update MANDATORY booking to change status from APPLICATION to BOOKED should invoice' => [ |
||
| 356 | [ |
||
| 357 | 'id' => 123, |
||
| 358 | 'previousStatus' => BookingStatus::Application, |
||
| 359 | 'status' => BookingStatus::Booked, |
||
| 360 | 'bookable' => [ |
||
| 361 | 'creditAccount' => true, |
||
| 362 | 'initialPrice' => Money::CHF(100), |
||
| 363 | 'periodicPrice' => Money::CHF(100), |
||
| 364 | 'bookingType' => BookingType::Mandatory, |
||
| 365 | ], |
||
| 366 | ], |
||
| 367 | 1, |
||
| 368 | ]; |
||
| 369 | yield 'update MANDATORY booking to change status from BOOKED to BOOKED should not invoice' => [ |
||
| 370 | [ |
||
| 371 | 'id' => 123, |
||
| 372 | 'previousStatus' => BookingStatus::Booked, |
||
| 373 | 'status' => BookingStatus::Booked, |
||
| 374 | 'bookable' => [ |
||
| 375 | 'creditAccount' => true, |
||
| 376 | 'initialPrice' => Money::CHF(100), |
||
| 377 | 'periodicPrice' => Money::CHF(100), |
||
| 378 | 'bookingType' => BookingType::Mandatory, |
||
| 379 | ], |
||
| 380 | ], |
||
| 381 | 0, |
||
| 382 | ]; |
||
| 383 | yield 'update MANDATORY booking to change status from PROCESSED to BOOKED should not invoice' => [ |
||
| 384 | [ |
||
| 385 | 'id' => 123, |
||
| 386 | 'previousStatus' => BookingStatus::Processed, |
||
| 387 | 'status' => BookingStatus::Booked, |
||
| 388 | 'bookable' => [ |
||
| 389 | 'creditAccount' => true, |
||
| 390 | 'initialPrice' => Money::CHF(100), |
||
| 391 | 'periodicPrice' => Money::CHF(100), |
||
| 392 | 'bookingType' => BookingType::Mandatory, |
||
| 393 | ], |
||
| 394 | ], |
||
| 395 | 0, |
||
| 396 | ]; |
||
| 397 | yield 'create ADMIN_APPROVED booking should invoice' => [ |
||
| 398 | [ |
||
| 399 | 'id' => null, |
||
| 400 | 'previousStatus' => null, |
||
| 401 | 'status' => BookingStatus::Booked, |
||
| 402 | 'bookable' => [ |
||
| 403 | 'creditAccount' => true, |
||
| 404 | 'initialPrice' => Money::CHF(100), |
||
| 405 | 'periodicPrice' => Money::CHF(100), |
||
| 406 | 'bookingType' => BookingType::AdminApproved, |
||
| 407 | ], |
||
| 408 | ], |
||
| 409 | 1, |
||
| 410 | ]; |
||
| 411 | yield 'update ADMIN_APPROVED booking should not invoice' => [ |
||
| 412 | [ |
||
| 413 | 'id' => 123, |
||
| 414 | 'previousStatus' => null, |
||
| 415 | 'status' => BookingStatus::Booked, |
||
| 416 | 'bookable' => [ |
||
| 417 | 'creditAccount' => true, |
||
| 418 | 'initialPrice' => Money::CHF(100), |
||
| 419 | 'periodicPrice' => Money::CHF(100), |
||
| 420 | 'bookingType' => BookingType::AdminApproved, |
||
| 421 | ], |
||
| 422 | ], |
||
| 423 | 0, |
||
| 424 | ]; |
||
| 425 | yield 'update ADMIN_APPROVED booking to change status from APPLICATION to BOOKED should invoice' => [ |
||
| 426 | [ |
||
| 427 | 'id' => 123, |
||
| 428 | 'previousStatus' => BookingStatus::Application, |
||
| 429 | 'status' => BookingStatus::Booked, |
||
| 430 | 'bookable' => [ |
||
| 431 | 'creditAccount' => true, |
||
| 432 | 'initialPrice' => Money::CHF(100), |
||
| 433 | 'periodicPrice' => Money::CHF(100), |
||
| 434 | 'bookingType' => BookingType::AdminApproved, |
||
| 435 | ], |
||
| 436 | ], |
||
| 437 | 1, |
||
| 438 | ]; |
||
| 441 |