
| Current Path : /var/www/html/sirius-pallets/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/sirius-pallets/vendor/league/container/src/Inflector/InflectorAggregate.php |
<?php
declare(strict_types=1);
namespace League\Container\Inflector;
use Generator;
use League\Container\ContainerAwareTrait;
class InflectorAggregate implements InflectorAggregateInterface
{
use ContainerAwareTrait;
/**
* @var Inflector[]
*/
protected $inflectors = [];
public function add(string $type, ?callable $callback = null): Inflector
{
$inflector = new Inflector($type, $callback);
$this->inflectors[] = $inflector;
return $inflector;
}
public function inflect($object)
{
foreach ($this->getIterator() as $inflector) {
$type = $inflector->getType();
if ($object instanceof $type) {
$inflector->setContainer($this->getContainer());
$inflector->inflect($object);
}
}
return $object;
}
public function getIterator(): Generator
{
yield from $this->inflectors;
}
}