RouteCollection::any()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Furious\Router\Collection;
6
7
use Furious\Router\Route\Route;
8
use Furious\Router\Route\RouteInterface;
9
10
final class RouteCollection
11
{
12
    private array $routes = [];
13
14
    public function add(RouteInterface $route): void
15
    {
16
        $this->routes[] = $route;
17
    }
18
19
    public function get(string $name, string $pattern, string $action, array $tokens = []): void
20
    {
21
        $this->add(new Route($name, $pattern, $action, ['GET'], $tokens));
22
    }
23
24
    public function post(string $name, string $pattern, string $action, array $tokens = []): void
25
    {
26
        $this->add(new Route($name, $pattern, $action, ['POST'], $tokens));
27
    }
28
29
    public function put(string $name, string $pattern, string $action, array $tokens = []): void
30
    {
31
        $this->add(new Route($name, $pattern, $action, ['PUT'], $tokens));
32
    }
33
34
    public function patch(string $name, string $pattern, string $action, array $tokens = []): void
35
    {
36
        $this->add(new Route($name, $pattern, $action, ['PATCH'], $tokens));
37
    }
38
39
    public function delete(string $name, string $pattern, string $action, array $tokens = []): void
40
    {
41
        $this->add(new Route($name, $pattern, $action, ['DELETE'], $tokens));
42
    }
43
44
    public function any(string $name, string $pattern, string $action, array $tokens = []): void
45
    {
46
        $this->add(new Route($name, $pattern, $action, [], $tokens));
47
    }
48
49
    /**
50
     * @return array|RouteInterface[]
51
     */
52
    public function getRoutes(): array
53
    {
54
        return $this->routes;
55
    }
56
}