1 | <?php |
||
24 | class Dispatcher |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * The current request object |
||
29 | * @var Request |
||
30 | */ |
||
31 | protected $request; |
||
32 | |||
33 | /** |
||
34 | * Dispatcher constructor. |
||
35 | * |
||
36 | * @param Request $request |
||
37 | * @param Config $config |
||
38 | * @param boolean $routeCacheEnabled |
||
39 | */ |
||
40 | public function __construct(Request $request, Config $config, $routeCacheEnabled = true) |
||
46 | |||
47 | /** |
||
48 | * Bootstrap for every route call |
||
49 | * |
||
50 | * @return Response|mixed |
||
51 | * @throws MethodNotFoundException |
||
52 | * @throws ClassNotFoundException |
||
53 | * @throws DispatchFailureException |
||
54 | */ |
||
55 | public function run() |
||
85 | |||
86 | /** |
||
87 | * Get data for specific route path |
||
88 | * |
||
89 | * @param string $path |
||
90 | * |
||
91 | * @return array |
||
92 | * @throws MethodNotFoundException |
||
93 | */ |
||
94 | private function getRoute($path) |
||
110 | |||
111 | /** |
||
112 | * Determines if we have a direct/static route match |
||
113 | * |
||
114 | * @param string $uri The request uri |
||
115 | * @param array $data The result from ClassParser |
||
116 | * |
||
117 | * @return array |
||
118 | * @throws MethodNotFoundException |
||
119 | */ |
||
120 | private function getDirectMatch(string $uri, array $data) |
||
139 | |||
140 | /** |
||
141 | * Determines if we have a variable route match |
||
142 | * |
||
143 | * @param string $uri |
||
144 | * @param array $data |
||
145 | * |
||
146 | * @return array |
||
147 | * @throws MethodNotFoundException |
||
148 | */ |
||
149 | private function getVariableMatch(string $uri, array $data) |
||
177 | |||
178 | /** |
||
179 | * Detect a form request |
||
180 | * |
||
181 | * @return boolean |
||
182 | */ |
||
183 | private function handleFormRequest() |
||
202 | |||
203 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: