Skip to content

Commit

Permalink
Can now register multiple calls to a single setter method
Browse files Browse the repository at this point in the history
  • Loading branch information
ekowabaka committed Sep 16, 2017
1 parent 714c382 commit d879228
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setActiveKey($activeKey)

public function call($method, $parameters = [])
{
$this->bindings[$this->activeKey]['calls'][$method] = $parameters;
$this->bindings[$this->activeKey]['calls'][] = [$method, $parameters];
}

public function setProperty($property, $binding)
Expand Down
6 changes: 3 additions & 3 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public function resolve($type, $constructorArguments = [])
$instance = $this->getInstance($resolvedClass['binding'], $constructorArguments);
}

foreach($resolvedClass['calls'] ?? [] as $method => $parameters) {
$method = new \ReflectionMethod($instance, $method);
$method->invokeArgs($instance, $this->getMethodArguments($method, $parameters));
foreach($resolvedClass['calls'] ?? [] as $calls) {
$method = new \ReflectionMethod($instance, $calls[0]);
$method->invokeArgs($instance, $this->getMethodArguments($method, $calls[1]));
}

return $instance;
Expand Down

0 comments on commit d879228

Please sign in to comment.