Pagination   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 36
ccs 2
cts 2
cp 1
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A matches() 0 3 1
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
The trait Cerbero\LazyJsonPages\Concerns\ParsesPages requires some properties which are not provided by Cerbero\LazyJsonPages\Paginations\Pagination: $itemsPointer, $value
Loading history...
24
    use ResolvesPages;
0 ignored issues
show
introduced by
The trait Cerbero\LazyJsonPages\Concerns\ResolvesPages requires some properties which are not provided by Cerbero\LazyJsonPages\Paginations\Pagination: $firstPage, $pageInPath, $pageName, $offsetKey
Loading history...
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
Bug introduced by
The property book is declared read-only in Cerbero\LazyJsonPages\Paginations\Pagination.
Loading history...
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