-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouterInterface.php
More file actions
94 lines (85 loc) · 2.16 KB
/
RouterInterface.php
File metadata and controls
94 lines (85 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @author : Jakiboy
* @package : FloatPHP
* @subpackage : Interfaces Classes Component
* @version : 1.5.x
* @copyright : (c) 2018 - 2025 Jihad Sinnaour <me@jihadsinnaour.com>
* @link : https://floatphp.com
* @license : MIT
*
* This file is a part of FloatPHP Framework.
*/
namespace FloatPHP\Interfaces\Classes;
interface RouterInterface
{
/**
* Create router from config.
*
* @param array $routes
* @param string $base
* @param array $types
*/
function __construct(array $routes = [], string $base = '', array $types = []);
/**
* Retrieves all routes,
* Useful if you want to process or display routes.
*
* @return array
*/
function getRoutes() : array;
/**
* Add multiple routes at once from array in the following format,
* [[method, route, controller, name, permission]].
*
* @param array $routes
* @return void
*/
function addRoutes(array $routes);
/**
* Set the base path.
*
* @param string $base
* @return void
*/
function setBase(string $base);
/**
* Add named match types.
*
* @param array $types
* @return void
*/
function addTypes(array $types);
/**
* Map route to target (controller),
* (GET|POST|PATCH|PUT|DELETE),
* Custom regex must start with an '@'.
*
* @param string $method
* @param string $route
* @param callable $controller
* @param string $name
* @param mixed $permission
* @return void
* @throws RouterException
*/
function map(string $method, string $route, $controller, ?string $name = null, $permission = null);
/**
* Reversed routing,
* Generate the URL for a named route.
*
* @param string $name
* @param array @params
* @return string
* @throws RouterException
*/
function generate(string $name, array $params = []) : string;
/**
* Match given request URL against stored routes.
*
* @param string $url
* @param string $method
* @return mixed
*/
function match(?string $url = null, ?string $method = null);
}