Completed
Push — master ( b10e46...20af00 )
by Christian
263:11
created

AbstractSitemapService::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[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
namespace Core23\SitemapBundle\Sitemap;
13
14
use Core23\SitemapBundle\Model\Url;
15
use Core23\SitemapBundle\Model\UrlInterface;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18
use Symfony\Component\Routing\RouterInterface;
19
20
abstract class AbstractSitemapService implements SitemapServiceInterface
21
{
22
    /**
23
     * @var RouterInterface
24
     */
25
    private $router;
26
27
    /**
28
     * @param RouterInterface $router
29
     */
30
    public function __construct(RouterInterface $router)
31
    {
32
        $this->router = $router;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function configureSettings(OptionsResolver $resolver): void
39
    {
40
    }
41
42
    /**
43
     * @param string $name
44
     * @param array  $parameters
45
     * @param int    $absolute
46
     *
47
     * @return string
48
     */
49
    final protected function generate($name, array $parameters = [], $absolute = UrlGeneratorInterface::ABSOLUTE_URL): string
50
    {
51
        return $this->router->generate($name, $parameters, $absolute);
52
    }
53
54
    /**
55
     * @param string         $location
56
     * @param int|null       $priority
57
     * @param string|null    $changeFreq
58
     * @param \DateTime|null $lastMod
59
     *
60
     * @return UrlInterface
61
     */
62
    final protected function createEntry(string $location, ?int $priority, ?string $changeFreq = null, ?\DateTime $lastMod = null): UrlInterface
63
    {
64
        return new Url($location, $priority, $changeFreq, $lastMod);
65
    }
66
}
67