RouteCollection::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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