WordPress at Your Fingertips
class is not described

Automattic\WooCommerce\Vendor\League\Container\Inflector

InflectorAggregate{} WC 1.0

No Hooks.

Return

null. Nothing.

Usage

$InflectorAggregate = new InflectorAggregate();
// use class methods

Methods

  1. add(string $type, callable $callback = null)
  2. getIterator()
  3. inflect($object)

Code of InflectorAggregate{} WC 5.5.2

<?php
class InflectorAggregate implements InflectorAggregateInterface
{
    use ContainerAwareTrait;

    /**
     * @var Inflector[]
     */
    protected $inflectors = [];

    /**
     * {@inheritdoc}
     */
    public function add(string $type, callable $callback = null) : Inflector
    {
        $inflector          = new Inflector($type, $callback);
        $this->inflectors[] = $inflector;

        return $inflector;
    }

    /**
     * {@inheritdoc}
     */
    public function getIterator() : Generator
    {
        $count = count($this->inflectors);

        for ($i = 0; $i < $count; $i++) {
            yield $this->inflectors[$i];
        }
    }

    /**
     * {@inheritdoc}
     */
    public function inflect($object)
    {
        foreach ($this->getIterator() as $inflector) {
            $type = $inflector->getType();

            if (! $object instanceof $type) {
                continue;
            }

            $inflector->setLeagueContainer($this->getLeagueContainer());
            $inflector->inflect($object);
        }

        return $object;
    }
}