1 | <?php |
||
9 | class Router implements RouterContract |
||
10 | { |
||
11 | /** |
||
12 | * @var RouteCollection|Route[] |
||
13 | */ |
||
14 | protected $routes; |
||
15 | |||
16 | /** |
||
17 | * All of the verbs supported by the router. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | public static $verbs = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']; |
||
22 | |||
23 | /** |
||
24 | * Router constructor. |
||
25 | */ |
||
26 | 9 | public function __construct() |
|
30 | |||
31 | /** |
||
32 | * @return RouteCollection|Route[] |
||
33 | */ |
||
34 | 8 | public function all() : RouteCollection |
|
38 | |||
39 | /** |
||
40 | * Register a new GET route with the router. |
||
41 | * |
||
42 | * @param string $uri |
||
43 | * @param \Closure|array|string $action |
||
44 | * |
||
45 | * @return Route |
||
46 | */ |
||
47 | 2 | public function get($uri, $action) |
|
51 | |||
52 | /** |
||
53 | * Register a new POST route with the router. |
||
54 | * |
||
55 | * @param string $uri |
||
56 | * @param \Closure|array|string $action |
||
57 | * |
||
58 | * @return Route |
||
59 | */ |
||
60 | 1 | public function post($uri, $action) |
|
64 | |||
65 | /** |
||
66 | * Register a new PUT route with the router. |
||
67 | * |
||
68 | * @param string $uri |
||
69 | * @param \Closure|array|string $action |
||
70 | * |
||
71 | * @return Route |
||
72 | */ |
||
73 | 1 | public function put($uri, $action) |
|
77 | |||
78 | /** |
||
79 | * Register a new PATCH route with the router. |
||
80 | * |
||
81 | * @param string $uri |
||
82 | * @param \Closure|array|string $action |
||
83 | * |
||
84 | * @return Route |
||
85 | */ |
||
86 | 1 | public function patch($uri, $action) |
|
90 | |||
91 | /** |
||
92 | * Register a new DELETE route with the router. |
||
93 | * |
||
94 | * @param string $uri |
||
95 | * @param \Closure|array|string $action |
||
96 | * |
||
97 | * @return Route |
||
98 | */ |
||
99 | 1 | public function delete($uri, $action) |
|
103 | |||
104 | /** |
||
105 | * Register a new OPTIONS route with the router. |
||
106 | * |
||
107 | * @param string $uri |
||
108 | * @param \Closure|array|string $action |
||
109 | * |
||
110 | * @return Route |
||
111 | */ |
||
112 | 1 | public function options($uri, $action) |
|
116 | |||
117 | /** |
||
118 | * Register a new route responding to all verbs. |
||
119 | * |
||
120 | * @param string $uri |
||
121 | * @param \Closure|array|string $action |
||
122 | * |
||
123 | * @return Route |
||
124 | */ |
||
125 | 1 | public function any($uri, $action) |
|
131 | |||
132 | /** |
||
133 | * Register a new route with the given verbs. |
||
134 | * |
||
135 | * @param array|string $methods |
||
136 | * @param string $uri |
||
137 | * @param \Closure|array|string $action |
||
138 | * |
||
139 | * @return Route |
||
140 | */ |
||
141 | 1 | public function match($methods, $uri, $action) |
|
145 | |||
146 | /** |
||
147 | * Add a route to the underlying route collection. |
||
148 | * |
||
149 | * @param array|string $methods |
||
150 | * @param string $uri |
||
151 | * @param \Closure|array|string $action |
||
152 | * |
||
153 | * @return Route |
||
154 | */ |
||
155 | 9 | protected function addRoute($methods, $uri, $action) |
|
161 | } |
||
162 |