1 | <?php |
||
22 | class ControllerDispatch |
||
23 | { |
||
24 | /** |
||
25 | * @var \ReflectionClass |
||
26 | */ |
||
27 | private $controllerClass; |
||
28 | |||
29 | /** |
||
30 | * @var \ReflectionMethod |
||
31 | */ |
||
32 | private $method; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $arguments; |
||
38 | |||
39 | /** |
||
40 | * Creates a Controller Dispatch |
||
41 | * |
||
42 | * @param string $controllerClassName |
||
43 | * @param string $method |
||
44 | * @param array $arguments |
||
45 | * |
||
46 | * @throws ControllerNotFoundException If controller class name does ot exits |
||
47 | * @throws BadControllerClassException If the provided class does not implement ControllerInterface |
||
48 | * @throws MissingControllerMethodException If provided method is not defined within the class |
||
49 | */ |
||
50 | public function __construct($controllerClassName, $method, array $arguments = []) |
||
61 | |||
62 | /** |
||
63 | * Controller class name |
||
64 | * |
||
65 | * @return \ReflectionClass |
||
66 | */ |
||
67 | public function controllerClass() |
||
71 | |||
72 | /** |
||
73 | * The method name that will be called to handle the request |
||
74 | * |
||
75 | * @return \ReflectionMethod |
||
76 | */ |
||
77 | public function handlerMethod() |
||
81 | |||
82 | /** |
||
83 | * A list of optional arguments to use when calling the request handler |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public function arguments() |
||
91 | |||
92 | /** |
||
93 | * Check if controller class exists |
||
94 | * |
||
95 | * @param $controllerClassName |
||
96 | * |
||
97 | * @throws ControllerNotFoundException if controller class name does ot exits |
||
98 | */ |
||
99 | private function checkClassExists($controllerClassName) |
||
107 | |||
108 | /** |
||
109 | * Check if controller class implements the ControllerInterface |
||
110 | * |
||
111 | * @param $controllerClassName |
||
112 | * |
||
113 | * @throws BadControllerClassException If the provided class does not implement ControllerInterface |
||
114 | */ |
||
115 | private function checkClassIsAController($controllerClassName) |
||
127 | |||
128 | /** |
||
129 | * Check if controller class has the provided method name |
||
130 | * |
||
131 | * @param string $method |
||
132 | * |
||
133 | * @throws MissingControllerMethodException If provided method is not defined within the class |
||
134 | */ |
||
135 | private function checkMethodExists($method) |
||
147 | } |
||
148 |