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

FactoryResult::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\Result;
6
7
/**
8
 * @author Kevin Bond <[email protected]>
9
 */
10
final class FactoryResult implements Result
11
{
12
    private $factory;
13
    private $result;
14
15
    public function __construct(callable $factory, Result $result)
16
    {
17
        $this->factory = $factory;
18
        $this->result = $result;
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function take($offset, $limit)
25
    {
26
        return new FactoryPage($this->factory, $this->result->take($offset, $limit));
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function count()
33
    {
34
        return $this->result->count();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getIterator()
41
    {
42
        foreach ($this->result as $result) {
43
            yield call_user_func($this->factory, $result);
44
        }
45
    }
46
}
47