3 namespace League\Container\Definition;
7 class ClassDefinition extends AbstractDefinition implements ClassDefinitionInterface
12 protected $methods = [];
17 public function withMethodCall($method, array $args = [])
30 public function withMethodCalls(array $methods = [])
32 foreach ($methods as $method => $args) {
33 $this->withMethodCall($method, $args);
42 public function build(array $args = [])
44 $args = (empty($args)) ? $this->arguments : $args;
45 $resolved = $this->resolveArguments($args);
46 $reflection = new ReflectionClass($this->concrete);
47 $instance = $reflection->newInstanceArgs($resolved);
49 return $this->invokeMethods($instance);
53 * Invoke methods on resolved instance.
55 * @param object $instance
58 protected function invokeMethods($instance)
60 foreach ($this->methods as $method) {
61 $args = $this->resolveArguments($method['arguments']);
62 call_user_func_array([$instance, $method['method']], $args);