Completed
Push — master ( 263533...6dddbe )
by Beñat
01:46
created

SymfonyEventsUrlGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A generate() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Shared Kernel library.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\SharedKernel\Infrastructure\Routing\Symfony;
15
16
use LIN3S\SharedKernel\Domain\Model\EventsUrlGenerator;
17
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18
19
/**
20
 * @author Beñat Espiña <[email protected]>
21
 */
22
final class SymfonyEventsUrlGenerator implements EventsUrlGenerator
23
{
24
    private $urlGenerator;
25
    private $pathName;
26
27
    public function __construct(UrlGeneratorInterface $urlGenerator, $pathName)
28
    {
29
        $this->urlGenerator = $urlGenerator;
30
        $this->pathName = $pathName;
31
    }
32
33
    public function generate(int $page) : string
34
    {
35
        return $this->urlGenerator->generate(
36
            $this->pathName,
37
            ['page' => (string) $page],
38
            UrlGeneratorInterface::ABSOLUTE_URL
39
        );
40
    }
41
}
42