11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Codelabmw \InfiniteScroll ;
46
7+ use Codelabmw \InfiniteScroll \Enums \PaginationType ;
58use Illuminate \Contracts \Pagination \CursorPaginator ;
69use Illuminate \Contracts \Pagination \Paginator ;
710use Illuminate \Database \Eloquent \Builder ;
811use Inertia \Inertia ;
9- use Codelabmw \InfiniteScroll \Enums \PaginationType ;
1012
11- class InfiniteScroll
13+ final class InfiniteScroll
1214{
1315 /**
1416 * Sets up infinite scrolling props for a given query.
15- *
16- * @param string $key
17- * @param Builder|CursorPaginator|Paginator $paginator
18- * @param int $perPage
19- * @param array<int, string> $columns
20- *
17+ *
18+ * @param array<int, string> $columns
2119 * @return array<string, mixed>
20+ *
21+ * @phpstan-ignore-next-line missingType.generics
2222 */
2323 public function make (string $ key , Builder |CursorPaginator |Paginator $ paginator , int $ perPage = 15 , array $ columns = ['* ' ]): array
2424 {
2525 if ($ paginator instanceof Paginator) {
2626 return [
27- $ key => Inertia::defer (fn () => $ paginator ->items ())->deepMerge (),
28- 'type ' => fn () => PaginationType::PAGED ,
29- 'page ' => fn () => $ paginator ->currentPage (),
30- 'hasMore ' => fn () => $ paginator ->hasMorePages (),
31- 'perPage ' => fn () => $ perPage ,
27+ $ key => Inertia::defer (fn () => $ paginator ->items ())->deepMerge (),
28+ 'type ' => fn (): PaginationType => PaginationType::PAGED ,
29+ 'page ' => fn () => $ paginator ->currentPage (),
30+ 'hasMore ' => fn () => $ paginator ->hasMorePages (),
31+ 'perPage ' => fn (): int => $ perPage ,
3232 ];
3333 }
3434
@@ -37,11 +37,11 @@ public function make(string $key, Builder|CursorPaginator|Paginator $paginator,
3737 }
3838
3939 return [
40- $ key => Inertia::defer (fn () => $ paginator ->items ())->deepMerge (),
41- 'type ' => fn () => PaginationType::CURSOR ,
42- 'cursor ' => fn () => $ paginator ->nextCursor ()?->encode(),
43- 'hasMore ' => fn () => $ paginator ->hasMorePages (),
44- 'perPage ' => fn () => $ perPage ,
40+ $ key => Inertia::defer (fn () => $ paginator ->items ())->deepMerge (),
41+ 'type ' => fn (): PaginationType => PaginationType::CURSOR ,
42+ 'cursor ' => fn () => $ paginator ->nextCursor ()?->encode(),
43+ 'hasMore ' => fn () => $ paginator ->hasMorePages (), // @phpstan-ignore-line method.notFound
44+ 'perPage ' => fn (): int => $ perPage ,
4545 ];
4646 }
47- }
47+ }
0 commit comments