UrlGeneratorService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A generateUrl() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Explicit Architecture POC,
7
 * which is created on top of the Symfony Demo application.
8
 *
9
 * (c) Herberto Graça <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Acme\App\Infrastructure\Router\Symfony;
16
17
use Acme\App\Core\Port\Router\UrlGeneratorInterface;
18
use Acme\App\Core\Port\Router\UrlType;
19
use Symfony\Component\Routing\Generator\UrlGeneratorInterface as SymfonyUrlGeneratorInterface;
20
21
final class UrlGeneratorService implements UrlGeneratorInterface
22
{
23
    /**
24
     * @var UrlGeneratorInterface
25
     */
26
    private $urlGenerator;
27
28
    public function __construct(SymfonyUrlGeneratorInterface $urlGenerator)
29
    {
30
        $this->urlGenerator = $urlGenerator;
0 ignored issues
show
Documentation Bug introduced by
It seems like $urlGenerator of type object<Symfony\Component...\UrlGeneratorInterface> is incompatible with the declared type object<Acme\App\Core\Por...\UrlGeneratorInterface> of property $urlGenerator.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
    }
32
33
    public function generateUrl(
34
        string $routeName,
35
        array $parameters = [],
36
        UrlType $urlType = null
37
    ): string {
38
        if (!$urlType) {
39
            $urlType = UrlType::absolutePath();
40
        }
41
42
        return $this->urlGenerator->generate($routeName, $parameters, $urlType->getValue());
0 ignored issues
show
Bug introduced by
The method generate() does not exist on Acme\App\Core\Port\Router\UrlGeneratorInterface. Did you maybe mean generateUrl()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
43
    }
44
}
45