Completed
Pull Request — master (#9)
by Jérémy
05:48 queued 02:29
created

RouteCollection   A

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
namespace RxThunder\Core\Router;
6
7
final class RouteCollection
8
{
9
    /** @var array<string, Route> */
10
    private array $routes = [];
11
12 5
    public function get(string $route_path): ?Route
13
    {
14 5
        return $this->routes[$route_path] ?? null;
15
    }
16
17
    /**
18
     * @return array<string, Route>
19
     */
20 1
    public function all(): array
21
    {
22 1
        return $this->routes;
23
    }
24
25 4
    public function add(Route $route): self
26
    {
27 4
        $this->routes[$route->getRoutePath()] = $route;
28
29 4
        return $this;
30
    }
31
}
32