1 | <?php |
||
10 | class Router extends EventEmitter |
||
11 | { |
||
12 | use WaterfallTrait; |
||
13 | /** |
||
14 | * The current routes list |
||
15 | * @var array |
||
16 | */ |
||
17 | public $routes = []; |
||
18 | |||
19 | /** |
||
20 | * The current asked uri |
||
21 | * @var string|boolean |
||
22 | */ |
||
23 | private $uri = false; |
||
24 | |||
25 | /** |
||
26 | * Create a new routing element |
||
27 | * |
||
28 | * @param array $routes a route array |
||
29 | * |
||
30 | * @throws \InvalidArgumentException |
||
31 | * @return Router |
||
|
|||
32 | */ |
||
33 | public function __construct($routes = []) |
||
41 | |||
42 | /** |
||
43 | * Add routes |
||
44 | * |
||
45 | * @param array $routes a route array |
||
46 | * |
||
47 | * @throws \InvalidArgumentException |
||
48 | * @return Void |
||
49 | */ |
||
50 | public function addRoutes($routes) |
||
62 | |||
63 | /** |
||
64 | * Add a new route |
||
65 | * |
||
66 | * @param String $method type of route |
||
67 | * @param String $route uri to catch |
||
68 | * @param Callable $callback |
||
69 | */ |
||
70 | public function addRoute($method, $route, $callback) |
||
74 | |||
75 | /** |
||
76 | * Create a new group of routes |
||
77 | * |
||
78 | * @param String $prefix prefix of thes routes |
||
79 | * |
||
80 | * @return \CapMousse\ReactRestify\Routing\Group |
||
81 | */ |
||
82 | public function addGroup($prefix, $callback) |
||
88 | |||
89 | /** |
||
90 | * Launch the route parsing |
||
91 | * |
||
92 | * @param \React\Http\Request $request |
||
93 | * @param \React\Restify\Response $response |
||
94 | * |
||
95 | * @throws \RuntimeException |
||
96 | * @return Void |
||
97 | */ |
||
98 | public function launch(Request $request, Response $response) |
||
120 | |||
121 | /** |
||
122 | * Try to match the current uri with all routes |
||
123 | * |
||
124 | * |
||
125 | * @param \React\Http\Request $request |
||
126 | * @param \React\Restify\Response $response |
||
127 | * |
||
128 | * @throws \RuntimeException |
||
129 | * @return Void |
||
130 | */ |
||
131 | private function matchRoutes(Request $request, Response $response) |
||
185 | } |
||
186 |
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.