1 | <?php |
||
9 | class Router extends EventEmitter |
||
10 | { |
||
11 | /** |
||
12 | * The current routes list |
||
13 | * @var array |
||
14 | */ |
||
15 | public $routes = array(); |
||
16 | |||
17 | /** |
||
18 | * The current asked uri |
||
19 | * @var string|boolean |
||
20 | */ |
||
21 | private $uri = false; |
||
22 | |||
23 | /** |
||
24 | * Create a new routing element |
||
25 | * |
||
26 | * @param array $routes a route array |
||
27 | * |
||
28 | * @throws \InvalidArgumentException |
||
29 | * @return Router |
||
|
|||
30 | */ |
||
31 | public function __construct($routes = array()) |
||
39 | |||
40 | /** |
||
41 | * Add routes |
||
42 | * |
||
43 | * @param array $routes a route array |
||
44 | * |
||
45 | * @throws \InvalidArgumentException |
||
46 | * @return Void |
||
47 | */ |
||
48 | public function addRoutes($routes) |
||
60 | |||
61 | /** |
||
62 | * Add a new route |
||
63 | * |
||
64 | * @param String $method type of route |
||
65 | * @param String $route uri to catch |
||
66 | * @param Callable $callback |
||
67 | */ |
||
68 | public function addRoute($method, $route, $callback) |
||
72 | |||
73 | /** |
||
74 | * Create a new group of routes |
||
75 | * |
||
76 | * @param String $prefix prefix of thes routes |
||
77 | * |
||
78 | * @return \CapMousse\ReactRestify\Routing\Group |
||
79 | */ |
||
80 | public function addGroup($prefix, $callback) |
||
86 | |||
87 | /** |
||
88 | * Launch the route parsing |
||
89 | * |
||
90 | * @param \React\Http\Request $request |
||
91 | * @param \React\Restify\Response $response |
||
92 | * |
||
93 | * @throws \RuntimeException |
||
94 | * @return Void |
||
95 | */ |
||
96 | public function launch(Request $request, Response $response, $next) |
||
110 | |||
111 | /** |
||
112 | * Try to match the current uri with all routes |
||
113 | * |
||
114 | * |
||
115 | * @param \React\Http\Request $request |
||
116 | * @param \React\Restify\Response $response |
||
117 | * |
||
118 | * @throws \RuntimeException |
||
119 | * @return Void |
||
120 | */ |
||
121 | private function matchRoutes(Request $request, Response $response, $next) |
||
165 | } |
||
166 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.