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

SymfonyEventsUrlGenerator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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