| Conditions | 1 |
| Paths | 1 |
| Total Lines | 196 |
| Code Lines | 147 |
| 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 |
||
| 428 | public function exceptionServiceProvider() |
||
| 429 | { |
||
| 430 | $authorUuid = Uuid::uuid4()->toString(); |
||
| 431 | $postUuid = Uuid::uuid4()->toString(); |
||
| 432 | $tagUuid = Uuid::uuid4()->toString(); |
||
| 433 | $trailUuid = Uuid::uuid4()->toString(); |
||
| 434 | |||
| 435 | $author = new Author('Davis', '[email protected]', 'Some string', $authorUuid, new DateTime()); |
||
| 436 | $post = new Post('A Post', 'Lorem ipsum', $author, $postUuid, [], null); |
||
| 437 | $tag = new Tag('A tag', $tagUuid); |
||
| 438 | $trail = new Trail('A trail', 'An amazing trail', $trailUuid, [$post]); |
||
| 439 | $filters = []; |
||
| 440 | |||
| 441 | return [ |
||
| 442 | [ |
||
| 443 | CreateAuthor::class, |
||
| 444 | 'save', |
||
| 445 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
| 446 | $author, |
||
| 447 | $this->createMock(LoggerInterface::class), |
||
| 448 | null, |
||
| 449 | 'Create author service' |
||
| 450 | ], |
||
| 451 | [ |
||
| 452 | EditAuthor::class, |
||
| 453 | 'save', |
||
| 454 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
| 455 | $author, |
||
| 456 | $this->createMock(LoggerInterface::class), |
||
| 457 | null, |
||
| 458 | 'Edit author service' |
||
| 459 | ], |
||
| 460 | [ |
||
| 461 | DeleteAuthor::class, |
||
| 462 | 'delete', |
||
| 463 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
| 464 | $author, |
||
| 465 | $this->createMock(LoggerInterface::class), |
||
| 466 | false, |
||
| 467 | 'Delete author service' |
||
| 468 | ], |
||
| 469 | [ |
||
| 470 | GetAuthor::class, |
||
| 471 | 'get', |
||
| 472 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
| 473 | $authorUuid, |
||
| 474 | $this->createMock(LoggerInterface::class), |
||
| 475 | null, |
||
| 476 | 'Get author service' |
||
| 477 | ], |
||
| 478 | [ |
||
| 479 | ListAuthors::class, |
||
| 480 | 'getList', |
||
| 481 | $this->getMockForAbstractClass(AbstractAuthorRepository::class), |
||
| 482 | $filters, |
||
| 483 | $this->createMock(LoggerInterface::class), |
||
| 484 | [], |
||
| 485 | 'List authors service' |
||
| 486 | ], |
||
| 487 | [ |
||
| 488 | CreatePost::class, |
||
| 489 | 'save', |
||
| 490 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
| 491 | $post, |
||
| 492 | $this->createMock(LoggerInterface::class), |
||
| 493 | null, |
||
| 494 | 'Create post service' |
||
| 495 | ], |
||
| 496 | [ |
||
| 497 | EditPost::class, |
||
| 498 | 'save', |
||
| 499 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
| 500 | $post, |
||
| 501 | $this->createMock(LoggerInterface::class), |
||
| 502 | null, |
||
| 503 | 'Edit post service' |
||
| 504 | ], |
||
| 505 | [ |
||
| 506 | DeletePost::class, |
||
| 507 | 'delete', |
||
| 508 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
| 509 | $post, |
||
| 510 | $this->createMock(LoggerInterface::class), |
||
| 511 | false, |
||
| 512 | 'Delete post service' |
||
| 513 | ], |
||
| 514 | [ |
||
| 515 | GetPost::class, |
||
| 516 | 'get', |
||
| 517 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
| 518 | $postUuid, |
||
| 519 | $this->createMock(LoggerInterface::class), |
||
| 520 | null, |
||
| 521 | 'Get post service' |
||
| 522 | ], |
||
| 523 | [ |
||
| 524 | ListPosts::class, |
||
| 525 | 'getList', |
||
| 526 | $this->getMockForAbstractClass(AbstractPostRepository::class), |
||
| 527 | $filters, |
||
| 528 | $this->createMock(LoggerInterface::class), |
||
| 529 | [], |
||
| 530 | 'List posts service' |
||
| 531 | ], |
||
| 532 | [ |
||
| 533 | CreateTag::class, |
||
| 534 | 'save', |
||
| 535 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
| 536 | $tag, |
||
| 537 | $this->createMock(LoggerInterface::class), |
||
| 538 | null, |
||
| 539 | 'Create tag service' |
||
| 540 | ], |
||
| 541 | [ |
||
| 542 | EditTag::class, |
||
| 543 | 'save', |
||
| 544 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
| 545 | $tag, |
||
| 546 | $this->createMock(LoggerInterface::class), |
||
| 547 | null, |
||
| 548 | 'Edit tag service' |
||
| 549 | ], |
||
| 550 | [ |
||
| 551 | DeleteTag::class, |
||
| 552 | 'delete', |
||
| 553 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
| 554 | $tag, |
||
| 555 | $this->createMock(LoggerInterface::class), |
||
| 556 | false, |
||
| 557 | 'Delete tag service' |
||
| 558 | ], |
||
| 559 | [ |
||
| 560 | GetTag::class, |
||
| 561 | 'get', |
||
| 562 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
| 563 | $tagUuid, |
||
| 564 | $this->createMock(LoggerInterface::class), |
||
| 565 | null, |
||
| 566 | 'Get tag service' |
||
| 567 | ], |
||
| 568 | [ |
||
| 569 | ListTags::class, |
||
| 570 | 'getList', |
||
| 571 | $this->getMockForAbstractClass(AbstractTagRepository::class), |
||
| 572 | $filters, |
||
| 573 | $this->createMock(LoggerInterface::class), |
||
| 574 | [], |
||
| 575 | 'List tags service' |
||
| 576 | ], |
||
| 577 | [ |
||
| 578 | CreateTrail::class, |
||
| 579 | 'save', |
||
| 580 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
| 581 | $trail, |
||
| 582 | $this->createMock(LoggerInterface::class), |
||
| 583 | null, |
||
| 584 | 'Create trail service' |
||
| 585 | ], |
||
| 586 | [ |
||
| 587 | EditTrail::class, |
||
| 588 | 'save', |
||
| 589 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
| 590 | $trail, |
||
| 591 | $this->createMock(LoggerInterface::class), |
||
| 592 | null, |
||
| 593 | 'Edit trail service' |
||
| 594 | ], |
||
| 595 | [ |
||
| 596 | DeleteTrail::class, |
||
| 597 | 'delete', |
||
| 598 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
| 599 | $trail, |
||
| 600 | $this->createMock(LoggerInterface::class), |
||
| 601 | false, |
||
| 602 | 'Delete trail service' |
||
| 603 | ], |
||
| 604 | [ |
||
| 605 | GetTrail::class, |
||
| 606 | 'get', |
||
| 607 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
| 608 | $trailUuid, |
||
| 609 | $this->createMock(LoggerInterface::class), |
||
| 610 | null, |
||
| 611 | 'Get trail service' |
||
| 612 | ], |
||
| 613 | [ |
||
| 614 | ListTrails::class, |
||
| 615 | 'getList', |
||
| 616 | $this->getMockForAbstractClass(AbstractTrailRepository::class), |
||
| 617 | $filters, |
||
| 618 | $this->createMock(LoggerInterface::class), |
||
| 619 | [], |
||
| 620 | 'List trails service' |
||
| 621 | ] |
||
| 622 | ]; |
||
| 623 | } |
||
| 624 | } |
||
| 625 |