1 | <?php |
||
13 | class CallbackResolver |
||
14 | { |
||
15 | /** |
||
16 | * @var Jarvis |
||
17 | */ |
||
18 | private $app; |
||
19 | |||
20 | public function __construct(Jarvis $app) |
||
24 | |||
25 | /** |
||
26 | * Resolves and replaces placeholders references by the parameter from Jarvis's |
||
27 | * dependency injection container. |
||
28 | * |
||
29 | * @param mixed $callback |
||
30 | * @return \Closure |
||
31 | */ |
||
32 | public function resolve($callback): \Closure |
||
40 | |||
41 | /** |
||
42 | * Resolves and returns an array of arguments according to the given closure. |
||
43 | * This method can also smartly type hint and find the right object to match |
||
44 | * callback requested arguments. |
||
45 | * |
||
46 | * @param \Closure $callback |
||
47 | * @param array $rawArgs |
||
48 | * @return array |
||
49 | */ |
||
50 | public function resolveArgumentsForClosure(\Closure $callback, array $rawArgs = []): array |
||
70 | |||
71 | /** |
||
72 | * Shortcut that calls successively ::resolve(), ::resolveArgumentsForClosure(), |
||
73 | * call_user_func_array() and returns the result. |
||
74 | * |
||
75 | * @param mixed $callback |
||
76 | * @param array $rawArgs |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function resolveAndCall($callback, array $rawArgs = []) |
||
88 | } |
||
89 |