LazyCompilableLink   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A compile() 0 8 2
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