Code

< 40 %
40-60 %
> 60 %
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