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 Reference by the parameter/service from Jarvis's |
||
27 | * dependency injection container. |
||
28 | * |
||
29 | * @param mixed $callback |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public function resolveReference($callback) |
||
42 | |||
43 | /** |
||
44 | * Resolves and replaces placeholders references by the parameter from Jarvis's |
||
45 | * dependency injection container. |
||
46 | * |
||
47 | * @param mixed $callback |
||
48 | * @return \Closure |
||
49 | */ |
||
50 | public function toClosure($callback): \Closure |
||
58 | |||
59 | /** |
||
60 | * Resolves and returns an array of arguments according to the given closure. |
||
61 | * This method can also smartly type hint and find the right object to match |
||
62 | * callback requested arguments. |
||
63 | * |
||
64 | * @param \Closure $callback |
||
65 | * @param array $rawArgs |
||
66 | * @return array |
||
67 | */ |
||
68 | public function resolveArgumentsForClosure(\Closure $callback, array $rawArgs = []): array |
||
88 | |||
89 | /** |
||
90 | * Shortcut that calls successively ::toClosure(), ::resolveArgumentsForClosure(), |
||
91 | * call_user_func_array() and returns the result. |
||
92 | * |
||
93 | * @param mixed $callback |
||
94 | * @param array $rawArgs |
||
95 | * @return mixed |
||
96 | */ |
||
97 | public function resolveAndCall($callback, array $rawArgs = []) |
||
106 | } |
||
107 |