Conditions | 5 |
Paths | 8 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function inject(Container $container, $service, array $serviceConfig) |
||
12 | { |
||
13 | $callConfig = array(); |
||
14 | |||
15 | if (array_key_exists('call', $serviceConfig)) { |
||
16 | $callConfig = $serviceConfig['call']; |
||
17 | } |
||
18 | |||
19 | foreach($callConfig as $methodName => $parameters) { |
||
20 | if (false !== strpos($methodName, '[')) { |
||
21 | if (preg_match('`^([^\[]*)\[[0-9]*\]$`i', $methodName, $matches)) { |
||
22 | $methodToCall = $matches[1]; |
||
23 | } |
||
24 | else { |
||
25 | throw new \RuntimeException(sprintf("Invalid method name '%s'", $methodName)); |
||
26 | } |
||
27 | } |
||
28 | else { |
||
29 | $methodToCall = $methodName; |
||
30 | } |
||
31 | |||
32 | $convertedParameters = $container->resolveMany($parameters); |
||
33 | call_user_func_array(array($service, $methodToCall), $convertedParameters); |
||
34 | } |
||
35 | |||
36 | return true; |
||
37 | } |
||
38 | } |
||
39 |