
| Current Path : /var/www/html/ift/vendor/league/container/src/Inflector/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/ift/vendor/league/container/src/Inflector/InflectorAggregate.php |
<?php
namespace League\Container\Inflector;
use League\Container\ImmutableContainerAwareTrait;
class InflectorAggregate implements InflectorAggregateInterface
{
use ImmutableContainerAwareTrait;
/**
* @var array
*/
protected $inflectors = [];
/**
* {@inheritdoc}
*/
public function add($type, callable $callback = null)
{
if (is_null($callback)) {
$inflector = new Inflector;
$this->inflectors[$type] = $inflector;
return $inflector;
}
$this->inflectors[$type] = $callback;
}
/**
* {@inheritdoc}
*/
public function inflect($object)
{
foreach ($this->inflectors as $type => $inflector) {
if (! $object instanceof $type) {
continue;
}
if ($inflector instanceof Inflector) {
$inflector->setContainer($this->getContainer());
$inflector->inflect($object);
continue;
}
// must be dealing with a callable as the inflector
call_user_func_array($inflector, [$object]);
}
return $object;
}
}