CollectionView   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 48
rs 10
c 0
b 0
f 0

6 Methods

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