Completed
Push — master ( 6c3bf7...0f5529 )
by Kevin
02:05
created

FactoryPage::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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;
14
15
    public function __construct(callable $factory, Page $page)
16
    {
17
        $this->factory = $factory;
18
        $this->page = $page;
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getCurrentOffset()
25
    {
26
        return $this->page->getCurrentOffset();
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getCurrentPage()
33
    {
34
        return $this->page->getCurrentPage();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getCurrentLimit()
41
    {
42
        return $this->page->getCurrentLimit();
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function count()
49
    {
50
        return $this->page->count();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function totalCount()
57
    {
58
        return $this->page->totalCount();
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getIterator()
65
    {
66
        foreach ($this->page as $result) {
67
            yield call_user_func($this->factory, $result);
68
        }
69
    }
70
}
71