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 toClosure($callback): \Closure |
||
44 | |||
45 | /** |
||
46 | * Resolves and returns an array of arguments according to the given closure. |
||
47 | * This method can also smartly type hint and find the right object to match |
||
48 | * callback requested arguments. |
||
49 | * |
||
50 | * @param \Closure $callback |
||
51 | * @param array $rawArgs |
||
52 | * @return array |
||
53 | */ |
||
54 | public function resolveArgumentsForClosure(\Closure $callback, array $rawArgs = []): array |
||
74 | |||
75 | /** |
||
76 | * Shortcut that calls successively ::toClosure(), ::resolveArgumentsForClosure(), |
||
77 | * call_user_func_array() and returns the result. |
||
78 | * |
||
79 | * @param mixed $callback |
||
80 | * @param array $rawArgs |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function resolveAndCall($callback, array $rawArgs = []) |
||
92 | } |
||
93 |