LazyCompilableLink::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Bankiru\Seo\Destination\Compiler;
4
5
use Bankiru\Seo\Destination\CompilableLinkInterface;
6
use Bankiru\Seo\Exception\LinkGeneratorException;
7
use Symfony\Component\Routing\Exception\ExceptionInterface;
8
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
9
10
final class LazyCompilableLink implements CompilableLinkInterface
11
{
12
    /** @var string */
13
    private $route;
14
    /** @var UrlGeneratorInterface */
15
    private $generator;
16
17
    /**
18
     * LazyCompilableLink constructor.
19
     *
20
     * @param string                $route
21
     * @param UrlGeneratorInterface $generator
22
     */
23 1
    public function __construct($route, UrlGeneratorInterface $generator)
24
    {
25 1
        $this->route     = $route;
26 1
        $this->generator = $generator;
27 1
    }
28
29
    /** {@inheritdoc} */
30 1
    public function compile(array $items)
31
    {
32
        try {
33 1
            return $this->generator->generate($this->route, $items);
34
        } catch (ExceptionInterface $e) {
35
            throw new LinkGeneratorException($e->getMessage(), $e->getCode(), $e);
36
        }
37
    }
38
}
39