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

RouteCollection::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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