Conditions | 1 |
Paths | 1 |
Total Lines | 264 |
Code Lines | 176 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | 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 |
||
407 | public function countProvider(): Generator |
||
408 | { |
||
409 | yield 'Ascending forward start inclusive' => [ |
||
410 | function (Table $posts) { |
||
411 | /** @var LampagerBehavior&Table $posts */ |
||
412 | return $posts->lampager() |
||
413 | ->forward() |
||
414 | ->seekable() |
||
415 | ->limit(3) |
||
416 | ->orderAsc('modified') |
||
417 | ->orderAsc('id') |
||
418 | ->count(); |
||
419 | }, |
||
420 | 3, |
||
421 | ]; |
||
422 | |||
423 | yield 'Ascending forward start exclusive' => [ |
||
424 | function (Table $posts) { |
||
425 | /** @var LampagerBehavior&Table $posts */ |
||
426 | return $posts->lampager() |
||
427 | ->forward() |
||
428 | ->seekable() |
||
429 | ->exclusive() |
||
430 | ->limit(3) |
||
431 | ->orderAsc('modified') |
||
432 | ->orderAsc('id') |
||
433 | ->count(); |
||
434 | }, |
||
435 | 3, |
||
436 | ]; |
||
437 | |||
438 | yield 'Ascending forward inclusive' => [ |
||
439 | function (Table $posts) { |
||
440 | /** @var LampagerBehavior&Table $posts */ |
||
441 | return $posts->lampager() |
||
442 | ->forward() |
||
443 | ->seekable() |
||
444 | ->limit(3) |
||
445 | ->orderAsc('modified') |
||
446 | ->orderAsc('id') |
||
447 | ->cursor([ |
||
448 | 'id' => 3, |
||
449 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
450 | ]) |
||
451 | ->count(); |
||
452 | }, |
||
453 | 3, |
||
454 | ]; |
||
455 | |||
456 | yield 'Ascending forward exclusive' => [ |
||
457 | function (Table $posts) { |
||
458 | /** @var LampagerBehavior&Table $posts */ |
||
459 | return $posts->lampager() |
||
460 | ->forward() |
||
461 | ->seekable() |
||
462 | ->exclusive() |
||
463 | ->limit(3) |
||
464 | ->orderAsc('modified') |
||
465 | ->orderAsc('id') |
||
466 | ->cursor([ |
||
467 | 'id' => 3, |
||
468 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
469 | ]) |
||
470 | ->count(); |
||
471 | }, |
||
472 | 3, |
||
473 | ]; |
||
474 | |||
475 | yield 'Ascending backward start inclusive' => [ |
||
476 | function (Table $posts) { |
||
477 | /** @var LampagerBehavior&Table $posts */ |
||
478 | return $posts->lampager() |
||
479 | ->backward() |
||
480 | ->seekable() |
||
481 | ->limit(3) |
||
482 | ->orderAsc('modified') |
||
483 | ->orderAsc('id') |
||
484 | ->count(); |
||
485 | }, |
||
486 | 3, |
||
487 | ]; |
||
488 | |||
489 | yield 'Ascending backward start exclusive' => [ |
||
490 | function (Table $posts) { |
||
491 | /** @var LampagerBehavior&Table $posts */ |
||
492 | return $posts->lampager() |
||
493 | ->backward() |
||
494 | ->seekable() |
||
495 | ->exclusive() |
||
496 | ->limit(3) |
||
497 | ->orderAsc('modified') |
||
498 | ->orderAsc('id') |
||
499 | ->count(); |
||
500 | }, |
||
501 | 3, |
||
502 | ]; |
||
503 | |||
504 | yield 'Ascending backward inclusive' => [ |
||
505 | function (Table $posts) { |
||
506 | /** @var LampagerBehavior&Table $posts */ |
||
507 | return $posts->lampager() |
||
508 | ->backward() |
||
509 | ->seekable() |
||
510 | ->limit(3) |
||
511 | ->orderAsc('modified') |
||
512 | ->orderAsc('id') |
||
513 | ->cursor([ |
||
514 | 'id' => 3, |
||
515 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
516 | ]) |
||
517 | ->count(); |
||
518 | }, |
||
519 | 2, |
||
520 | ]; |
||
521 | |||
522 | yield 'Ascending backward exclusive' => [ |
||
523 | function (Table $posts) { |
||
524 | /** @var LampagerBehavior&Table $posts */ |
||
525 | return $posts->lampager() |
||
526 | ->backward() |
||
527 | ->seekable() |
||
528 | ->exclusive() |
||
529 | ->limit(3) |
||
530 | ->orderAsc('modified') |
||
531 | ->orderAsc('id') |
||
532 | ->cursor([ |
||
533 | 'id' => 3, |
||
534 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
535 | ]) |
||
536 | ->count(); |
||
537 | }, |
||
538 | 1, |
||
539 | ]; |
||
540 | |||
541 | yield 'Descending forward start inclusive' => [ |
||
542 | function (Table $posts) { |
||
543 | /** @var LampagerBehavior&Table $posts */ |
||
544 | return $posts->lampager() |
||
545 | ->forward() |
||
546 | ->seekable() |
||
547 | ->limit(3) |
||
548 | ->orderDesc('modified') |
||
549 | ->orderDesc('id') |
||
550 | ->count(); |
||
551 | }, |
||
552 | 3, |
||
553 | ]; |
||
554 | |||
555 | yield 'Descending forward start exclusive' => [ |
||
556 | function (Table $posts) { |
||
557 | /** @var LampagerBehavior&Table $posts */ |
||
558 | return $posts->lampager() |
||
559 | ->forward() |
||
560 | ->seekable() |
||
561 | ->exclusive() |
||
562 | ->limit(3) |
||
563 | ->orderDesc('modified') |
||
564 | ->orderDesc('id') |
||
565 | ->count(); |
||
566 | }, |
||
567 | 3, |
||
568 | ]; |
||
569 | |||
570 | yield 'Descending forward inclusive' => [ |
||
571 | function (Table $posts) { |
||
572 | /** @var LampagerBehavior&Table $posts */ |
||
573 | return $posts->lampager() |
||
574 | ->forward() |
||
575 | ->seekable() |
||
576 | ->limit(3) |
||
577 | ->orderDesc('modified') |
||
578 | ->orderDesc('id') |
||
579 | ->cursor([ |
||
580 | 'id' => 3, |
||
581 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
582 | ]) |
||
583 | ->count(); |
||
584 | }, |
||
585 | 2, |
||
586 | ]; |
||
587 | |||
588 | yield 'Descending forward exclusive' => [ |
||
589 | function (Table $posts) { |
||
590 | /** @var LampagerBehavior&Table $posts */ |
||
591 | return $posts->lampager() |
||
592 | ->forward() |
||
593 | ->seekable() |
||
594 | ->exclusive() |
||
595 | ->limit(3) |
||
596 | ->orderDesc('modified') |
||
597 | ->orderDesc('id') |
||
598 | ->cursor([ |
||
599 | 'id' => 3, |
||
600 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
601 | ]) |
||
602 | ->count(); |
||
603 | }, |
||
604 | 1, |
||
605 | ]; |
||
606 | |||
607 | yield 'Descending backward start inclusive' => [ |
||
608 | function (Table $posts) { |
||
609 | /** @var LampagerBehavior&Table $posts */ |
||
610 | return $posts->lampager() |
||
611 | ->backward() |
||
612 | ->seekable() |
||
613 | ->limit(3) |
||
614 | ->orderDesc('modified') |
||
615 | ->orderDesc('id') |
||
616 | ->count(); |
||
617 | }, |
||
618 | 3, |
||
619 | ]; |
||
620 | |||
621 | yield 'Descending backward start exclusive' => [ |
||
622 | function (Table $posts) { |
||
623 | /** @var LampagerBehavior&Table $posts */ |
||
624 | return $posts->lampager() |
||
625 | ->backward() |
||
626 | ->seekable() |
||
627 | ->exclusive() |
||
628 | ->limit(3) |
||
629 | ->orderDesc('modified') |
||
630 | ->orderDesc('id') |
||
631 | ->count(); |
||
632 | }, |
||
633 | 3, |
||
634 | ]; |
||
635 | |||
636 | yield 'Descending backward inclusive' => [ |
||
637 | function (Table $posts) { |
||
638 | /** @var LampagerBehavior&Table $posts */ |
||
639 | return $posts->lampager() |
||
640 | ->backward() |
||
641 | ->seekable() |
||
642 | ->limit(3) |
||
643 | ->orderDesc('modified') |
||
644 | ->orderDesc('id') |
||
645 | ->cursor([ |
||
646 | 'id' => 3, |
||
647 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
648 | ]) |
||
649 | ->count(); |
||
650 | }, |
||
651 | 3, |
||
652 | ]; |
||
653 | |||
654 | yield 'Descending backward exclusive' => [ |
||
655 | function (Table $posts) { |
||
656 | /** @var LampagerBehavior&Table $posts */ |
||
657 | return $posts->lampager() |
||
658 | ->backward() |
||
659 | ->seekable() |
||
660 | ->exclusive() |
||
661 | ->limit(3) |
||
662 | ->orderDesc('modified') |
||
663 | ->orderDesc('id') |
||
664 | ->cursor([ |
||
665 | 'id' => 3, |
||
666 | 'modified' => new FrozenTime('2017-01-01 10:00:00'), |
||
667 | ]) |
||
668 | ->count(); |
||
669 | }, |
||
670 | 3, |
||
671 | ]; |
||
674 |