Conditions | 1 |
Paths | 1 |
Total Lines | 573 |
Code Lines | 377 |
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 |
||
654 | public static function queryExpressionProvider(): Generator |
||
655 | { |
||
656 | yield 'Ascending forward start inclusive with QueryExpression' => [ |
||
657 | function (Table $posts) { |
||
658 | /** @var LampagerBehavior&Table $posts */ |
||
659 | return $posts->lampager() |
||
660 | ->forward() |
||
661 | ->seekable() |
||
662 | ->limit(3) |
||
663 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
664 | ->orderByAsc($posts->selectQuery()->expr('id')); |
||
665 | }, |
||
666 | new PaginationResult( |
||
667 | [ |
||
668 | new Entity([ |
||
669 | 'id' => 1, |
||
670 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
671 | ]), |
||
672 | new Entity([ |
||
673 | 'id' => 3, |
||
674 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
675 | ]), |
||
676 | new Entity([ |
||
677 | 'id' => 5, |
||
678 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
679 | ]), |
||
680 | ], |
||
681 | [ |
||
682 | 'hasPrevious' => null, |
||
683 | 'previousCursor' => null, |
||
684 | 'hasNext' => true, |
||
685 | 'nextCursor' => [ |
||
686 | 'id' => 2, |
||
687 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
688 | ], |
||
689 | ] |
||
690 | ), |
||
691 | ]; |
||
692 | |||
693 | yield 'Ascending forward inclusive with QueryExpression' => [ |
||
694 | function (Table $posts) { |
||
695 | /** @var LampagerBehavior&Table $posts */ |
||
696 | return $posts->lampager() |
||
697 | ->forward() |
||
698 | ->seekable() |
||
699 | ->limit(3) |
||
700 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
701 | ->orderByAsc($posts->selectQuery()->expr('id')) |
||
702 | ->cursor([ |
||
703 | 'id' => 3, |
||
704 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
705 | ]); |
||
706 | }, |
||
707 | new PaginationResult( |
||
708 | [ |
||
709 | new Entity([ |
||
710 | 'id' => 3, |
||
711 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
712 | ]), |
||
713 | new Entity([ |
||
714 | 'id' => 5, |
||
715 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
716 | ]), |
||
717 | new Entity([ |
||
718 | 'id' => 2, |
||
719 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
720 | ]), |
||
721 | ], |
||
722 | [ |
||
723 | 'hasPrevious' => true, |
||
724 | 'previousCursor' => [ |
||
725 | 'id' => 1, |
||
726 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
727 | ], |
||
728 | 'hasNext' => true, |
||
729 | 'nextCursor' => [ |
||
730 | 'id' => 4, |
||
731 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
732 | ], |
||
733 | ] |
||
734 | ), |
||
735 | ]; |
||
736 | |||
737 | yield 'Ascending forward exclusive with QueryExpression' => [ |
||
738 | function (Table $posts) { |
||
739 | /** @var LampagerBehavior&Table $posts */ |
||
740 | return $posts->lampager() |
||
741 | ->forward() |
||
742 | ->seekable() |
||
743 | ->exclusive() |
||
744 | ->limit(3) |
||
745 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
746 | ->orderByAsc($posts->selectQuery()->expr('id')) |
||
747 | ->cursor([ |
||
748 | 'id' => 3, |
||
749 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
750 | ]); |
||
751 | }, |
||
752 | new PaginationResult( |
||
753 | [ |
||
754 | new Entity([ |
||
755 | 'id' => 5, |
||
756 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
757 | ]), |
||
758 | new Entity([ |
||
759 | 'id' => 2, |
||
760 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
761 | ]), |
||
762 | new Entity([ |
||
763 | 'id' => 4, |
||
764 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
765 | ]), |
||
766 | ], |
||
767 | [ |
||
768 | 'hasPrevious' => true, |
||
769 | 'previousCursor' => [ |
||
770 | 'id' => 5, |
||
771 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
772 | ], |
||
773 | 'hasNext' => false, |
||
774 | 'nextCursor' => null, |
||
775 | ] |
||
776 | ), |
||
777 | ]; |
||
778 | |||
779 | yield 'Ascending backward start inclusive with QueryExpression' => [ |
||
780 | function (Table $posts) { |
||
781 | /** @var LampagerBehavior&Table $posts */ |
||
782 | return $posts->lampager() |
||
783 | ->backward() |
||
784 | ->seekable() |
||
785 | ->limit(3) |
||
786 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
787 | ->orderByAsc($posts->selectQuery()->expr('id')); |
||
788 | }, |
||
789 | new PaginationResult( |
||
790 | [ |
||
791 | new Entity([ |
||
792 | 'id' => 5, |
||
793 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
794 | ]), |
||
795 | new Entity([ |
||
796 | 'id' => 2, |
||
797 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
798 | ]), |
||
799 | new Entity([ |
||
800 | 'id' => 4, |
||
801 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
802 | ]), |
||
803 | ], |
||
804 | [ |
||
805 | 'hasPrevious' => true, |
||
806 | 'previousCursor' => [ |
||
807 | 'id' => 3, |
||
808 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
809 | ], |
||
810 | 'hasNext' => null, |
||
811 | 'nextCursor' => null, |
||
812 | ] |
||
813 | ), |
||
814 | ]; |
||
815 | |||
816 | yield 'Ascending backward start exclusive with QueryExpression' => [ |
||
817 | function (Table $posts) { |
||
818 | /** @var LampagerBehavior&Table $posts */ |
||
819 | return $posts->lampager() |
||
820 | ->backward() |
||
821 | ->seekable() |
||
822 | ->exclusive() |
||
823 | ->limit(3) |
||
824 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
825 | ->orderByAsc($posts->selectQuery()->expr('id')); |
||
826 | }, |
||
827 | new PaginationResult( |
||
828 | [ |
||
829 | new Entity([ |
||
830 | 'id' => 5, |
||
831 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
832 | ]), |
||
833 | new Entity([ |
||
834 | 'id' => 2, |
||
835 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
836 | ]), |
||
837 | new Entity([ |
||
838 | 'id' => 4, |
||
839 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
840 | ]), |
||
841 | ], |
||
842 | [ |
||
843 | 'hasPrevious' => true, |
||
844 | 'previousCursor' => [ |
||
845 | 'id' => 5, |
||
846 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
847 | ], |
||
848 | 'hasNext' => null, |
||
849 | 'nextCursor' => null, |
||
850 | ] |
||
851 | ), |
||
852 | ]; |
||
853 | |||
854 | yield 'Ascending backward inclusive with QueryExpression' => [ |
||
855 | function (Table $posts) { |
||
856 | /** @var LampagerBehavior&Table $posts */ |
||
857 | return $posts->lampager() |
||
858 | ->backward() |
||
859 | ->seekable() |
||
860 | ->limit(3) |
||
861 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
862 | ->orderByAsc($posts->selectQuery()->expr('id')) |
||
863 | ->cursor([ |
||
864 | 'id' => 3, |
||
865 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
866 | ]); |
||
867 | }, |
||
868 | new PaginationResult( |
||
869 | [ |
||
870 | new Entity([ |
||
871 | 'id' => 1, |
||
872 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
873 | ]), |
||
874 | new Entity([ |
||
875 | 'id' => 3, |
||
876 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
877 | ]), |
||
878 | ], |
||
879 | [ |
||
880 | 'hasPrevious' => false, |
||
881 | 'previousCursor' => null, |
||
882 | 'hasNext' => true, |
||
883 | 'nextCursor' => [ |
||
884 | 'id' => 5, |
||
885 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
886 | ], |
||
887 | ] |
||
888 | ), |
||
889 | ]; |
||
890 | |||
891 | yield 'Ascending backward exclusive with QueryExpression' => [ |
||
892 | function (Table $posts) { |
||
893 | /** @var LampagerBehavior&Table $posts */ |
||
894 | return $posts->lampager() |
||
895 | ->backward() |
||
896 | ->seekable() |
||
897 | ->exclusive() |
||
898 | ->limit(3) |
||
899 | ->orderByAsc($posts->selectQuery()->expr('modified')) |
||
900 | ->orderByAsc($posts->selectQuery()->expr('id')) |
||
901 | ->cursor([ |
||
902 | 'id' => 3, |
||
903 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
904 | ]); |
||
905 | }, |
||
906 | new PaginationResult( |
||
907 | [ |
||
908 | new Entity([ |
||
909 | 'id' => 1, |
||
910 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
911 | ]), |
||
912 | ], |
||
913 | [ |
||
914 | 'hasPrevious' => false, |
||
915 | 'previousCursor' => null, |
||
916 | 'hasNext' => true, |
||
917 | 'nextCursor' => [ |
||
918 | 'id' => 1, |
||
919 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
920 | ], |
||
921 | ] |
||
922 | ), |
||
923 | ]; |
||
924 | |||
925 | yield 'Descending forward start inclusive with QueryExpression' => [ |
||
926 | function (Table $posts) { |
||
927 | /** @var LampagerBehavior&Table $posts */ |
||
928 | return $posts->lampager() |
||
929 | ->forward() |
||
930 | ->seekable() |
||
931 | ->limit(3) |
||
932 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
933 | ->orderByDesc($posts->selectQuery()->expr('id')); |
||
934 | }, |
||
935 | new PaginationResult( |
||
936 | [ |
||
937 | new Entity([ |
||
938 | 'id' => 4, |
||
939 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
940 | ]), |
||
941 | new Entity([ |
||
942 | 'id' => 2, |
||
943 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
944 | ]), |
||
945 | new Entity([ |
||
946 | 'id' => 5, |
||
947 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
948 | ]), |
||
949 | ], |
||
950 | [ |
||
951 | 'hasPrevious' => null, |
||
952 | 'previousCursor' => null, |
||
953 | 'hasNext' => true, |
||
954 | 'nextCursor' => [ |
||
955 | 'id' => 3, |
||
956 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
957 | ], |
||
958 | ] |
||
959 | ), |
||
960 | ]; |
||
961 | |||
962 | yield 'Descending forward start exclusive with QueryExpression' => [ |
||
963 | function (Table $posts) { |
||
964 | /** @var LampagerBehavior&Table $posts */ |
||
965 | return $posts->lampager() |
||
966 | ->forward() |
||
967 | ->seekable() |
||
968 | ->exclusive() |
||
969 | ->limit(3) |
||
970 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
971 | ->orderByDesc($posts->selectQuery()->expr('id')); |
||
972 | }, |
||
973 | new PaginationResult( |
||
974 | [ |
||
975 | new Entity([ |
||
976 | 'id' => 4, |
||
977 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
978 | ]), |
||
979 | new Entity([ |
||
980 | 'id' => 2, |
||
981 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
982 | ]), |
||
983 | new Entity([ |
||
984 | 'id' => 5, |
||
985 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
986 | ]), |
||
987 | ], |
||
988 | [ |
||
989 | 'hasPrevious' => null, |
||
990 | 'previousCursor' => null, |
||
991 | 'hasNext' => true, |
||
992 | 'nextCursor' => [ |
||
993 | 'id' => 5, |
||
994 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
995 | ], |
||
996 | ] |
||
997 | ), |
||
998 | ]; |
||
999 | |||
1000 | yield 'Descending forward inclusive with QueryExpression' => [ |
||
1001 | function (Table $posts) { |
||
1002 | /** @var LampagerBehavior&Table $posts */ |
||
1003 | return $posts->lampager() |
||
1004 | ->forward() |
||
1005 | ->seekable() |
||
1006 | ->limit(3) |
||
1007 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1008 | ->orderByDesc($posts->selectQuery()->expr('id')) |
||
1009 | ->cursor([ |
||
1010 | 'id' => 3, |
||
1011 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1012 | ]); |
||
1013 | }, |
||
1014 | new PaginationResult( |
||
1015 | [ |
||
1016 | new Entity([ |
||
1017 | 'id' => 3, |
||
1018 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1019 | ]), |
||
1020 | new Entity([ |
||
1021 | 'id' => 1, |
||
1022 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1023 | ]), |
||
1024 | ], |
||
1025 | [ |
||
1026 | 'hasPrevious' => true, |
||
1027 | 'previousCursor' => [ |
||
1028 | 'id' => 5, |
||
1029 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1030 | ], |
||
1031 | 'hasNext' => false, |
||
1032 | 'nextCursor' => null, |
||
1033 | ] |
||
1034 | ), |
||
1035 | ]; |
||
1036 | |||
1037 | yield 'Descending forward exclusive with QueryExpression' => [ |
||
1038 | function (Table $posts) { |
||
1039 | /** @var LampagerBehavior&Table $posts */ |
||
1040 | return $posts->lampager() |
||
1041 | ->forward() |
||
1042 | ->seekable() |
||
1043 | ->exclusive() |
||
1044 | ->limit(3) |
||
1045 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1046 | ->orderByDesc($posts->selectQuery()->expr('id')) |
||
1047 | ->cursor([ |
||
1048 | 'id' => 3, |
||
1049 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1050 | ]); |
||
1051 | }, |
||
1052 | new PaginationResult( |
||
1053 | [ |
||
1054 | new Entity([ |
||
1055 | 'id' => 1, |
||
1056 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1057 | ]), |
||
1058 | ], |
||
1059 | [ |
||
1060 | 'hasPrevious' => true, |
||
1061 | 'previousCursor' => [ |
||
1062 | 'id' => 1, |
||
1063 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1064 | ], |
||
1065 | 'hasNext' => false, |
||
1066 | 'nextCursor' => null, |
||
1067 | ] |
||
1068 | ), |
||
1069 | ]; |
||
1070 | |||
1071 | yield 'Descending backward start inclusive with QueryExpression' => [ |
||
1072 | function (Table $posts) { |
||
1073 | /** @var LampagerBehavior&Table $posts */ |
||
1074 | return $posts->lampager() |
||
1075 | ->backward() |
||
1076 | ->seekable() |
||
1077 | ->limit(3) |
||
1078 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1079 | ->orderByDesc($posts->selectQuery()->expr('id')); |
||
1080 | }, |
||
1081 | new PaginationResult( |
||
1082 | [ |
||
1083 | new Entity([ |
||
1084 | 'id' => 5, |
||
1085 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1086 | ]), |
||
1087 | new Entity([ |
||
1088 | 'id' => 3, |
||
1089 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1090 | ]), |
||
1091 | new Entity([ |
||
1092 | 'id' => 1, |
||
1093 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1094 | ]), |
||
1095 | ], |
||
1096 | [ |
||
1097 | 'hasPrevious' => true, |
||
1098 | 'previousCursor' => [ |
||
1099 | 'id' => 2, |
||
1100 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
1101 | ], |
||
1102 | 'hasNext' => null, |
||
1103 | 'nextCursor' => null, |
||
1104 | ] |
||
1105 | ), |
||
1106 | ]; |
||
1107 | |||
1108 | yield 'Descending backward start exclusive with QueryExpression' => [ |
||
1109 | function (Table $posts) { |
||
1110 | /** @var LampagerBehavior&Table $posts */ |
||
1111 | return $posts->lampager() |
||
1112 | ->backward() |
||
1113 | ->seekable() |
||
1114 | ->exclusive() |
||
1115 | ->limit(3) |
||
1116 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1117 | ->orderByDesc($posts->selectQuery()->expr('id')); |
||
1118 | }, |
||
1119 | new PaginationResult( |
||
1120 | [ |
||
1121 | new Entity([ |
||
1122 | 'id' => 5, |
||
1123 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1124 | ]), |
||
1125 | new Entity([ |
||
1126 | 'id' => 3, |
||
1127 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1128 | ]), |
||
1129 | new Entity([ |
||
1130 | 'id' => 1, |
||
1131 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1132 | ]), |
||
1133 | ], |
||
1134 | [ |
||
1135 | 'hasPrevious' => true, |
||
1136 | 'previousCursor' => [ |
||
1137 | 'id' => 5, |
||
1138 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1139 | ], |
||
1140 | 'hasNext' => null, |
||
1141 | 'nextCursor' => null, |
||
1142 | ] |
||
1143 | ), |
||
1144 | ]; |
||
1145 | |||
1146 | yield 'Descending backward inclusive with QueryExpression' => [ |
||
1147 | function (Table $posts) { |
||
1148 | /** @var LampagerBehavior&Table $posts */ |
||
1149 | return $posts->lampager() |
||
1150 | ->backward() |
||
1151 | ->seekable() |
||
1152 | ->limit(3) |
||
1153 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1154 | ->orderByDesc($posts->selectQuery()->expr('id')) |
||
1155 | ->cursor([ |
||
1156 | 'id' => 3, |
||
1157 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1158 | ]); |
||
1159 | }, |
||
1160 | new PaginationResult( |
||
1161 | [ |
||
1162 | new Entity([ |
||
1163 | 'id' => 2, |
||
1164 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
1165 | ]), |
||
1166 | new Entity([ |
||
1167 | 'id' => 5, |
||
1168 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1169 | ]), |
||
1170 | new Entity([ |
||
1171 | 'id' => 3, |
||
1172 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1173 | ]), |
||
1174 | ], |
||
1175 | [ |
||
1176 | 'hasPrevious' => true, |
||
1177 | 'previousCursor' => [ |
||
1178 | 'id' => 4, |
||
1179 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
1180 | ], |
||
1181 | 'hasNext' => true, |
||
1182 | 'nextCursor' => [ |
||
1183 | 'id' => 1, |
||
1184 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1185 | ], |
||
1186 | ] |
||
1187 | ), |
||
1188 | ]; |
||
1189 | |||
1190 | yield 'Descending backward exclusive with QueryExpression' => [ |
||
1191 | function (Table $posts) { |
||
1192 | /** @var LampagerBehavior&Table $posts */ |
||
1193 | return $posts->lampager() |
||
1194 | ->backward() |
||
1195 | ->seekable() |
||
1196 | ->exclusive() |
||
1197 | ->limit(3) |
||
1198 | ->orderByDesc($posts->selectQuery()->expr('modified')) |
||
1199 | ->orderByDesc($posts->selectQuery()->expr('id')) |
||
1200 | ->cursor([ |
||
1201 | 'id' => 3, |
||
1202 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1203 | ]); |
||
1204 | }, |
||
1205 | new PaginationResult( |
||
1206 | [ |
||
1207 | new Entity([ |
||
1208 | 'id' => 4, |
||
1209 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
1210 | ]), |
||
1211 | new Entity([ |
||
1212 | 'id' => 2, |
||
1213 | 'modified' => new DateTime('2017-01-01 11:00:00'), |
||
1214 | ]), |
||
1215 | new Entity([ |
||
1216 | 'id' => 5, |
||
1217 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1218 | ]), |
||
1219 | ], |
||
1220 | [ |
||
1221 | 'hasPrevious' => false, |
||
1222 | 'previousCursor' => null, |
||
1223 | 'hasNext' => true, |
||
1224 | 'nextCursor' => [ |
||
1225 | 'id' => 5, |
||
1226 | 'modified' => new DateTime('2017-01-01 10:00:00'), |
||
1227 | ], |
||
1233 |