FactoryPage   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 40
rs 10
c 1
b 0
f 1
ccs 17
cts 17
cp 1
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A currentLimit() 0 3 1
A getIterator() 0 4 2
A totalCount() 0 3 1
A count() 0 3 1
A currentOffset() 0 3 1
A __construct() 0 4 1
A currentPage() 0 3 1
1
<?php
2
3
namespace Zenstruck\Porpaginas\Factory;
4
5
use Zenstruck\Porpaginas\Page;
6
7
/**
8
 * @author Kevin Bond <[email protected]>
9
 */
10
final class FactoryPage implements Page
11
{
12
    private $factory;
13
    private Page $page;
14
15 8
    public function __construct(callable $factory, Page $page)
16
    {
17 8
        $this->factory = $factory;
18 8
        $this->page = $page;
19 8
    }
20
21 2
    public function currentOffset(): int
22
    {
23 2
        return $this->page->currentOffset();
24
    }
25
26 2
    public function currentPage(): int
27
    {
28 2
        return $this->page->currentPage();
29
    }
30
31 2
    public function currentLimit(): int
32
    {
33 2
        return $this->page->currentLimit();
34
    }
35
36 5
    public function count(): int
37
    {
38 5
        return $this->page->count();
39
    }
40
41 1
    public function totalCount(): int
42
    {
43 1
        return $this->page->totalCount();
44
    }
45
46 6
    public function getIterator(): \Traversable
47
    {
48 6
        foreach ($this->page as $result) {
49 5
            yield \call_user_func($this->factory, $result);
50
        }
51 6
    }
52
}
53