RouteNameGenerator::generateRouteName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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