RouteNameGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateRouteName() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Routing\Route;
6
7
use LAG\AdminBundle\Metadata\AdminResource;
8
use LAG\AdminBundle\Metadata\OperationInterface;
9
10
use function Symfony\Component\String\u;
11
12
class RouteNameGenerator implements RouteNameGeneratorInterface
13
{
14
    public function generateRouteName(AdminResource $admin, OperationInterface $operation): string
15
    {
16
        return u($admin->getRoutePattern())
17
            ->replace('{resource}', $admin->getName())
0 ignored issues
show
Bug introduced by
It seems like $admin->getName() can also be of type null; however, parameter $to of Symfony\Component\String\UnicodeString::replace() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

17
            ->replace('{resource}', /** @scrutinizer ignore-type */ $admin->getName())
Loading history...
18
            ->replace('{operation}', $operation->getName())
19
            ->lower()
20
            ->toString()
21
        ;
22
    }
23
}
24