Nelmio\Alice\Generator\Resolver\UniqueValuesPool::add PHP Method

add() public method

public add ( UniqueValue $value )
$value Nelmio\Alice\Definition\Value\UniqueValue
    public function add(UniqueValue $value)
    {
        $valueId = $value->getId();
        if (false === array_key_exists($valueId, $this->pool)) {
            $this->pool[$valueId] = [];
        }
        $this->pool[$valueId][] = $value->getValue();
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  *
  * @param UniqueValue $value
  *
  * @throws UniqueValueGenerationLimitReachedException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context, int $tryCounter = 0) : ResolvedValueWithFixtureSet
 {
     $this->checkResolver(__METHOD__);
     $tryCounter = $this->incrementCounter($tryCounter, $value, $this->limit);
     /**
      * @var UniqueValue        $generatedValue
      * @var ResolvedFixtureSet $fixtureSet
      */
     list($generatedValue, $fixtureSet) = $this->generateValue($value, $fixture, $fixtureSet, $scope, $context);
     if ($this->pool->has($generatedValue)) {
         return $this->resolve($value, $fixture, $fixtureSet, $scope, $context, $tryCounter);
     }
     $this->pool->add($generatedValue);
     return new ResolvedValueWithFixtureSet($generatedValue->getValue(), $fixtureSet);
 }
All Usage Examples Of Nelmio\Alice\Generator\Resolver\UniqueValuesPool::add