Passed
Push — master ( 913337...3b593e )
by Michael
04:37
created

SymfonyUrlGeneratorRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLink() 0 6 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Mapper\Handler\LinkRepository;
5
6
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
7
8
/**
9
 * A link-repository implementation based on the Symfony Router component.
10
 *
11
 * @see http://symfony.com/doc/current/routing.html
12
 *
13
 * @package Mikemirten\Component\JsonApi\Mapper\Handler\LinkRepository
14
 */
15
class SymfonyUrlGeneratorRepository implements RepositoryInterface
16
{
17
    /**
18
     * Symfony url generator
19
     *
20
     * @var UrlGeneratorInterface
21
     */
22
    protected $generator;
23
24
    /**
25
     * SymfonyRouterRepository constructor.
26
     *
27
     * @param UrlGeneratorInterface $generator
28
     */
29 1
    public function __construct(UrlGeneratorInterface $generator)
30
    {
31 1
        $this->generator = $generator;
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function getLink(string $name, array $parameters): Link
38
    {
39 1
        $reference = $this->generator->generate($name, $parameters);
40
41 1
        return new Link($reference);
42
    }
43
}