Destination   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 41
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRoute() 0 4 1
A resolve() 0 9 2
A getIterator() 0 4 1
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