Completed
Pull Request — master (#36)
by Daniel
09:34 queued 06:14
created

CollectionView::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A CollectionView::next() 0 4 1
1
<?php
2
3
namespace Psi\Component\ContentType\Standard\View;
4
5
use Psi\Component\ContentType\View\ViewFactory;
6
use Psi\Component\ContentType\View\ViewInterface;
7
8
class CollectionView implements ViewInterface, \Iterator
9
{
10
    private $collection;
11
    private $factory;
12
    private $template;
13
    private $viewType;
14
    private $viewOptions;
15
16
    public function __construct(
17
        string $template,
18
        ViewFactory $factory,
19
        \Traversable $collection,
20
        string $viewType,
21
        array $viewOptions
22
    ) {
23
        $this->template = $template;
24
        $this->factory = $factory;
25
        $this->collection = $collection;
26
        $this->viewType = $viewType;
27
        $this->viewOptions = $viewOptions;
28
    }
29
30
    public function getTemplate(): string
31
    {
32
        return $this->template;
33
    }
34
35
    public function current()
36
    {
37
        return $this->factory->create(
38
            $this->viewType,
39
            current($this->collection),
40
            $this->viewOptions
41
        );
42
    }
43
44
    public function next()
45
    {
46
        next($this->collection);
47
    }
48
49
    public function key()
50
    {
51
        return key($this->collection);
52
    }
53
54
    public function rewind()
55
    {
56
        reset($this->collection);
57
    }
58
59
    public function valid()
60
    {
61
        return key($this->collection) !== null;
62
    }
63
}
64