| Total Complexity | 7 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class FallbackGenerator implements UrlGeneratorInterface |
||
| 8 | { |
||
| 9 | private UrlGeneratorInterface $urlGenerator; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * FallbackGenerator constructor. |
||
| 13 | */ |
||
| 14 | public function __construct(UrlGeneratorInterface $urlGenerator) |
||
| 15 | { |
||
| 16 | $this->urlGenerator = $urlGenerator; |
||
| 17 | } |
||
| 18 | |||
| 19 | public function generate(string $name, array $parameters = []): string |
||
| 20 | { |
||
| 21 | try { |
||
| 22 | return $this->urlGenerator->generate($name, $parameters); |
||
| 23 | } catch (RouteNotFoundException $e) { |
||
| 24 | // generate fallback URL |
||
| 25 | } |
||
|
|
|||
| 26 | } |
||
| 27 | |||
| 28 | public function generateAbsolute(string $name, array $parameters = [], string $scheme = null, string $host = null): string |
||
| 29 | { |
||
| 30 | try { |
||
| 31 | return $this->urlGenerator->generateAbsolute($name, $parameters, $scheme, $host); |
||
| 32 | } catch (RouteNotFoundException $e) { |
||
| 33 | // generate fallback URL |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getUriPrefix(): string |
||
| 38 | { |
||
| 39 | return $this->urlGenerator->getUriPrefix(); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function setUriPrefix(string $name): void |
||
| 45 | } |
||
| 46 | } |
||
| 47 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: