Destination::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 6
cp 0.6667
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2.1481
1
<?php
2
namespace Bankiru\Seo;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\Common\Collections\Collection;
6
7
final class Destination implements \IteratorAggregate, DestinationInterface
8
{
9
    /** @var string */
10
    private $route;
11
    /** @var Collection */
12
    private $items;
13
14
    /**
15
     * @param string $route
16
     * @param array  $items
17
     */
18 14
    public function __construct($route, array $items)
19
    {
20 14
        $this->route = $route;
21 14
        $this->items = new ArrayCollection($items);
22 14
    }
23
24 9
    public function getIterator()
25
    {
26 9
        return $this->items->getIterator();
27
    }
28
29
    /**
30
     * @return string
31
     */
32 13
    public function getRoute()
33
    {
34 13
        return $this->route;
35
    }
36
37
    /** {@inheritdoc} */
38 8
    public function resolve($key)
39
    {
40 8
        $value = $this->items->get($key);
41 8
        if (is_callable($value)) {
42
            $value = $value();
43
        }
44
45 8
        return $value;
46
    }
47
}
48