| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class RouteCollection implements RouteCollectionInterface |
||
| 11 | { |
||
| 12 | use DispatcherAwareTrait; |
||
| 13 | use HandlerAwareTrait; |
||
| 14 | |||
| 15 | private array $routes; |
||
| 16 | |||
| 17 | public function __construct($routes = []) |
||
| 18 | { |
||
| 19 | $this->routes = $routes; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function addRoute(RouteInterface $route): self |
||
| 23 | { |
||
| 24 | $new = clone $this; |
||
| 25 | $new->routes[] = $route; |
||
| 26 | |||
| 27 | return $new; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function addRoutes(array $routes): self |
||
| 31 | { |
||
| 32 | // TODO: Implement addRoutes() method. |
||
| 33 | } |
||
|
|
|||
| 34 | |||
| 35 | public function addCollection(RouteCollectionInterface $collection): self |
||
| 37 | // TODO: Implement addCollection() method. |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getRoutes(): iterable |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
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: