PathCollection   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 80.95%

Importance

Changes 0
Metric Value
wmc 9
eloc 12
dl 0
loc 72
ccs 17
cts 21
cp 0.8095
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A valid() 0 3 1
A rewind() 0 3 1
A count() 0 3 1
A key() 0 3 1
A next() 0 3 1
A __construct() 0 4 2
A add() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Twig\Business\Model\Path;
6
7
8
use Xervice\Twig\Business\Dependency\Path\PathProviderInterface;
9
10
class PathCollection implements \Iterator, \Countable
11
{
12
    /**
13
     * @var \Xervice\Twig\Business\Dependency\Path\PathProviderInterface[]
14
     */
15
    private $collection;
16
17
    /**
18
     * @var int
19
     */
20
    private $position;
21
22
    /**
23
     * Collection constructor.
24
     *
25
     * @param \Xervice\Twig\Business\Dependency\Path\PathProviderInterface[] $collection
26
     */
27 2
    public function __construct(array $collection)
28
    {
29 2
        foreach ($collection as $validator) {
30 2
            $this->add($validator);
31
        }
32 2
    }
33
34
    /**
35
     * @param \Xervice\Twig\Business\Dependency\Path\PathProviderInterface $validator
36
     */
37 2
    public function add(PathProviderInterface $validator): void
38
    {
39 2
        $this->collection[] = $validator;
40 2
    }
41
42
    /**
43
     * @return \Xervice\Twig\Business\Dependency\Path\PathProviderInterface
44
     */
45 2
    public function current(): PathProviderInterface
46
    {
47 2
        return $this->collection[$this->position];
48
    }
49
50 2
    public function next(): void
51
    {
52 2
        $this->position++;
53 2
    }
54
55
    /**
56
     * @return int
57
     */
58
    public function key(): int
59
    {
60
        return $this->position;
61
    }
62
63
    /**
64
     * @return bool
65
     */
66 2
    public function valid(): bool
67
    {
68 2
        return isset($this->collection[$this->position]);
69
    }
70
71 2
    public function rewind(): void
72
    {
73 2
        $this->position = 0;
74 2
    }
75
76
    /**
77
     * @return int
78
     */
79
    public function count(): int
80
    {
81
        return \count($this->collection);
82
    }
83
}