Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.3332 |
Changes | 0 |
1 | <?php |
||
38 | 3 | public function generateUrl($route, $parameters = []) |
|
39 | { |
||
40 | 3 | if (!$route) { |
|
41 | return ''; |
||
42 | } |
||
43 | |||
44 | 3 | $parameters = $this->getParameters($parameters); |
|
|
|||
45 | |||
46 | try { |
||
47 | 3 | $uri = $this->router->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH); |
|
48 | } catch (\Exception $exception) { |
||
49 | return ''; |
||
50 | } |
||
51 | |||
52 | 3 | $url = rtrim($this->siteUrl, '/') . '/' . ltrim($uri, '/'); |
|
53 | |||
54 | 3 | return $url; |
|
55 | } |
||
56 | |||
74 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.