3 namespace League\Container\Inflector;
5 use League\Container\ImmutableContainerAwareTrait;
7 class InflectorAggregate implements InflectorAggregateInterface
9 use ImmutableContainerAwareTrait;
14 protected $inflectors = [];
19 public function add($type, callable $callback = null)
21 if (is_null($callback)) {
22 $inflector = new Inflector;
23 $this->inflectors[$type] = $inflector;
28 $this->inflectors[$type] = $callback;
34 public function inflect($object)
36 foreach ($this->inflectors as $type => $inflector) {
37 if (! $object instanceof $type) {
41 if ($inflector instanceof Inflector) {
42 $inflector->setContainer($this->getContainer());
43 $inflector->inflect($object);
47 // must be dealing with a callable as the inflector
48 call_user_func_array($inflector, [$object]);