Passed
Branch feature/first-release (57b0a8)
by Andrea Marco
13:40
created

TotalPagesHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 3 2
A handle() 0 3 1
1
<?php
2
3
namespace Cerbero\LazyJsonPages\Handlers;
4
5
use Cerbero\LazyJsonPages\Concerns\HandlesTotalPages;
6
use Traversable;
7
8
/**
9
 * The total pages handler.
10
 *
11
 */
12
class TotalPagesHandler extends AbstractHandler
13
{
14
    use HandlesTotalPages;
0 ignored issues
show
introduced by
The trait Cerbero\LazyJsonPages\Concerns\HandlesTotalPages requires some properties which are not provided by Cerbero\LazyJsonPages\Handlers\TotalPagesHandler: $chunk, $source, $request, $path, $firstPage, $concurrency, $pageName, $timeout
Loading history...
15
16
    /**
17
     * Determine whether the handler can handle the APIs configuration
18
     *
19
     * @return bool
20
     */
21
    public function matches(): bool
22
    {
23
        return $this->config->pages > 0 && $this->config->perPageQuery === null;
24
    }
25
26
    /**
27
     * Handle the APIs configuration
28
     *
29
     * @return Traversable
30
     */
31
    public function handle(): Traversable
32
    {
33
        yield from $this->handleByTotalPages($this->config->pages);
34
    }
35
}
36