1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Cerbero\LazyJsonPages\Paginations; |
||
6 | |||
7 | use Cerbero\LazyJsonPages\Concerns\ParsesPages; |
||
8 | use Cerbero\LazyJsonPages\Concerns\ResolvesPages; |
||
9 | use Cerbero\LazyJsonPages\Data\Config; |
||
10 | use Cerbero\LazyJsonPages\Services\Book; |
||
11 | use Cerbero\LazyJsonPages\Sources\AnySource; |
||
12 | use GuzzleHttp\Client; |
||
13 | use IteratorAggregate; |
||
14 | use Traversable; |
||
15 | |||
16 | /** |
||
17 | * The abstract implementation of a pagination. |
||
18 | * |
||
19 | * @implements IteratorAggregate<int, mixed> |
||
20 | */ |
||
21 | abstract class Pagination implements IteratorAggregate |
||
22 | { |
||
23 | use ParsesPages; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
24 | use ResolvesPages; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | /** |
||
27 | * The collector of pages. |
||
28 | */ |
||
29 | public readonly Book $book; |
||
30 | |||
31 | /** |
||
32 | * Yield the paginated items. |
||
33 | * |
||
34 | * @return Traversable<int, mixed> |
||
35 | */ |
||
36 | abstract public function getIterator(): Traversable; |
||
37 | |||
38 | /** |
||
39 | * Instantiate the class. |
||
40 | */ |
||
41 | 50 | final public function __construct( |
|
42 | protected readonly AnySource $source, |
||
43 | protected readonly Client $client, |
||
44 | protected readonly Config $config, |
||
45 | ) { |
||
46 | 50 | $this->book = new Book(); |
|
0 ignored issues
–
show
|
|||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Determine whether this pagination matches the configuration. |
||
51 | * |
||
52 | * @codeCoverageIgnore |
||
53 | */ |
||
54 | public function matches(): bool |
||
55 | { |
||
56 | return true; |
||
57 | } |
||
58 | } |
||
59 |