| 1 | <?php |
||
| 4 | class Route |
||
| 5 | { |
||
| 6 | private $methods; |
||
| 7 | private $uri; |
||
| 8 | private $handler; |
||
| 9 | private $name; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Creates a new Route. |
||
| 13 | * |
||
| 14 | * @param array|string $methods |
||
| 15 | * Either a single HTTP verb, or an array of verbs. |
||
| 16 | * @param string $uri |
||
| 17 | * URI pattern to match for this route. |
||
| 18 | * @param string $handler |
||
| 19 | * ClassName::methodName to invoke for this route. If methodName |
||
| 20 | * is not present, a method of 'index' is assumed. |
||
| 21 | * @param string $name |
||
| 22 | * (Optional) An unique name for this route. |
||
| 23 | */ |
||
| 24 | 20 | public function __construct($methods, $uri, $handler, $name = null) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * Get methods registered for this route. |
||
| 34 | * |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | 9 | public function methods() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Get the URI defined for this route. |
||
| 44 | * |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | 9 | public function uri() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Get the handler defined for this route. |
||
| 54 | * |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | 9 | public function handler() |
|
| 61 | |||
| 62 | /** |
||
| 63 | * Get the name defined for this route, or null if undefined. |
||
| 64 | * |
||
| 65 | * @return string|null |
||
| 66 | */ |
||
| 67 | 9 | public function name() |
|
| 71 | } |
||
| 72 |