|
3 | 3 | * @author : Jakiboy |
4 | 4 | * @package : FloatPHP |
5 | 5 | * @subpackage : Interfaces Classes Component |
6 | | - * @version : 1.1.0 |
| 6 | + * @version : 1.2.x |
7 | 7 | * @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]> |
8 | 8 | * @link : https://floatphp.com |
9 | 9 | * @license : MIT |
|
16 | 16 | interface RouterInterface |
17 | 17 | { |
18 | 18 | /** |
| 19 | + * Create router from config. |
| 20 | + * |
19 | 21 | * @param array $routes |
20 | | - * @param string $basePath |
21 | | - * @param array $matchTypes |
| 22 | + * @param string $base |
| 23 | + * @param array $types |
22 | 24 | */ |
23 | | - function __construct($routes = [], $basePath = '', $matchTypes = []); |
| 25 | + function __construct(array $routes = [], string $base = '', array $types = []); |
24 | 26 |
|
25 | 27 | /** |
| 28 | + * Retrieves all routes, |
| 29 | + * Useful if you want to process or display routes. |
| 30 | + * |
26 | 31 | * @return array |
27 | 32 | */ |
28 | | - function getRoutes(); |
| 33 | + function getRoutes() : array; |
29 | 34 |
|
30 | 35 | /** |
| 36 | + * Add multiple routes at once from array in the following format, |
| 37 | + * [[method, route, controller, name, permission]]. |
| 38 | + * |
31 | 39 | * @param array $routes |
32 | 40 | * @return void |
33 | 41 | */ |
34 | | - function addRoutes($routes); |
| 42 | + function addRoutes(array $routes); |
35 | 43 |
|
36 | 44 | /** |
37 | | - * @param string $basePath |
| 45 | + * Set the base path. |
| 46 | + * |
| 47 | + * @param string $base |
38 | 48 | * @return void |
39 | 49 | */ |
40 | | - function setBasePath($basePath); |
| 50 | + function setBase(string $base); |
41 | 51 |
|
42 | 52 | /** |
43 | | - * @param array $matchTypes |
| 53 | + * Add named match types. |
| 54 | + * |
| 55 | + * @param array $types |
44 | 56 | * @return void |
45 | 57 | */ |
46 | | - function addMatchTypes($matchTypes); |
| 58 | + function addTypes(array $types); |
47 | 59 |
|
48 | 60 | /** |
49 | | - * @param string $routeName |
| 61 | + * Map route to target (controller), |
| 62 | + * (GET|POST|PATCH|PUT|DELETE), |
| 63 | + * Custom regex must start with an '@'. |
| 64 | + * |
| 65 | + * @param string $method |
| 66 | + * @param string $route |
| 67 | + * @param callable $controller |
| 68 | + * @param string $name |
| 69 | + * @param mixed $permission |
| 70 | + * @return void |
| 71 | + * @throws RouterException |
| 72 | + */ |
| 73 | + function map(string $method, string $route, $controller, ?string $name = null, $permission = null); |
| 74 | + |
| 75 | + /** |
| 76 | + * Reversed routing, |
| 77 | + * Generate the URL for a named route. |
| 78 | + * |
| 79 | + * @param string $name |
50 | 80 | * @param array @params |
51 | 81 | * @return string |
52 | | - * @throws Exception |
| 82 | + * @throws RouterException |
53 | 83 | */ |
54 | | - function generate($routeName, $params = []); |
| 84 | + function generate(string $name, array $params = []) : string; |
55 | 85 |
|
56 | 86 | /** |
57 | | - * @param string $requestUrl |
58 | | - * @param string $requestMethod |
59 | | - * @return array|boolean |
| 87 | + * Match given request URL against stored routes. |
| 88 | + * |
| 89 | + * @param string $url |
| 90 | + * @param string $method |
| 91 | + * @return mixed |
60 | 92 | */ |
61 | | - function match($requestUrl = null, $requestMethod = null); |
| 93 | + function match(?string $url = null, ?string $method = null); |
62 | 94 | } |
0 commit comments