| 1 | <?php |
||
| 14 | class Base implements Route |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Route methog, eg.: GET, POST, ... |
||
| 18 | * |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $method; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Route handler, can be callable or array, this is connected |
||
| 25 | * with the selected dispatcher. |
||
| 26 | * |
||
| 27 | * @var mixed |
||
| 28 | */ |
||
| 29 | private $handler; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Route url eg. /foo/bar |
||
| 33 | * |
||
| 34 | * @var string |
||
| 35 | */ |
||
| 36 | private $url; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Route constructor |
||
| 40 | * |
||
| 41 | * @param String $method |
||
| 42 | * @param String $url |
||
| 43 | * @param Mixed $handler |
||
| 44 | */ |
||
| 45 | public function __construct($method, $url, $handler) |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Sets route method |
||
| 54 | * |
||
| 55 | * @param string $method route method |
||
| 56 | * |
||
| 57 | * @return self for fluent interface |
||
| 58 | */ |
||
| 59 | public function setMethod($method) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Get route method |
||
| 68 | * |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function getMethod() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Sets URL for route |
||
| 78 | * |
||
| 79 | * @param mixed $url route url |
||
| 80 | * |
||
| 81 | * @return self for fluent interface |
||
| 82 | */ |
||
| 83 | public function setUrl($url) |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Get URL of route |
||
| 92 | * |
||
| 93 | * @return string |
||
| 94 | */ |
||
| 95 | public function getUrl() |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Sets handler that will be executed if the url will match the route. |
||
| 102 | * |
||
| 103 | * @param mixed $handler handler which will be executed if the url will |
||
| 104 | * match the route |
||
| 105 | * |
||
| 106 | * @return self for fluent interface |
||
| 107 | */ |
||
| 108 | public function setHandler($handler) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Get handler |
||
| 117 | * |
||
| 118 | * @return mixed |
||
| 119 | */ |
||
| 120 | public function getHandler() |
||
| 124 | } |
||
| 125 |