RouteCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A add() 0 5 1
A get() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Thunder micro CLI framework.
7
 * (c) Jérémy Marodon <[email protected]>
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace RxThunder\Core\Router;
13
14
final class RouteCollection
15
{
16
    /** @var array<string, Route> */
17
    private array $routes = [];
18
19 5
    public function get(string $route_path): ?Route
20
    {
21 5
        return $this->routes[$route_path] ?? null;
22
    }
23
24
    /**
25
     * @return array<string, Route>
26
     */
27 1
    public function all(): array
28
    {
29 1
        return $this->routes;
30
    }
31
32 4
    public function add(Route $route): self
33
    {
34 4
        $this->routes[$route->path()] = $route;
35
36 4
        return $this;
37
    }
38
}
39