1 | <?php namespace Arcanedev\RouteViewer\Entities; |
||
13 | class Route implements Arrayable, Jsonable, JsonSerializable |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** @var array */ |
||
21 | public $methods = []; |
||
22 | |||
23 | /** @var string */ |
||
24 | public $uri; |
||
25 | |||
26 | /** @var array */ |
||
27 | public $params = []; |
||
28 | |||
29 | /** @var string */ |
||
30 | public $action; |
||
31 | |||
32 | /** @var string */ |
||
33 | public $name; |
||
34 | |||
35 | /** @var array */ |
||
36 | public $middleware; |
||
37 | |||
38 | /** @var string|null */ |
||
39 | public $domain; |
||
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Constructor |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Route constructor. |
||
48 | * |
||
49 | * @param array $methods |
||
50 | * @param string $uri |
||
51 | * @param string|null $name |
||
52 | * @param string|null $action |
||
53 | * @param array $middleware |
||
54 | * @param string|null $domain |
||
55 | */ |
||
56 | 24 | public function __construct(array $methods, $uri, $action, $name, array $middleware, $domain = null) |
|
65 | |||
66 | /* ----------------------------------------------------------------- |
||
67 | | Getters & Setters |
||
68 | | ----------------------------------------------------------------- |
||
69 | */ |
||
70 | |||
71 | /** |
||
72 | * Set the route URI. |
||
73 | * |
||
74 | * @param string $uri |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | 24 | private function setUri($uri) |
|
87 | |||
88 | /** |
||
89 | * Get the action namespace. |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 6 | public function getActionNamespace() |
|
97 | |||
98 | /** |
||
99 | * Get the action method. |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 6 | public function getActionMethod() |
|
107 | |||
108 | /* ----------------------------------------------------------------- |
||
109 | | Check Methods |
||
110 | | ----------------------------------------------------------------- |
||
111 | */ |
||
112 | |||
113 | /** |
||
114 | * Check if the route has name. |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 6 | public function hasName() |
|
122 | |||
123 | /** |
||
124 | * Check if the route has domain. |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | 3 | public function hasDomain() |
|
132 | |||
133 | /** |
||
134 | * Check if the route has middleware. |
||
135 | * |
||
136 | * @return bool |
||
137 | */ |
||
138 | 3 | public function hasMiddleware() |
|
142 | |||
143 | /** |
||
144 | * Check if the action is a closure function. |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | 9 | public function isClosure() |
|
152 | |||
153 | /* ----------------------------------------------------------------- |
||
154 | | Other Methods |
||
155 | | ----------------------------------------------------------------- |
||
156 | */ |
||
157 | |||
158 | /** |
||
159 | * Get the instance as an array. |
||
160 | * |
||
161 | * @return array |
||
162 | */ |
||
163 | 6 | public function toArray() |
|
175 | |||
176 | /** |
||
177 | * Convert the object into something JSON serializable. |
||
178 | * |
||
179 | * @return array |
||
180 | */ |
||
181 | 3 | public function jsonSerialize() |
|
185 | |||
186 | /** |
||
187 | * Convert the object to its JSON representation. |
||
188 | * |
||
189 | * @param int $options |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | 3 | public function toJson($options = 0) |
|
197 | } |
||
198 |