Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\UniqueValueDenormalizer::generateValue PHP Method

generateValue() private method

private generateValue ( Nelmio\Alice\FixtureInterface $scope, FlagBag $flags, mixed | Nelmio\Alice\Definition\ValueInterface $value ) : Nelmio\Alice\Definition\ValueInterface
$scope Nelmio\Alice\FixtureInterface
$flags Nelmio\Alice\Definition\FlagBag
$value mixed | Nelmio\Alice\Definition\ValueInterface
return Nelmio\Alice\Definition\ValueInterface
    private function generateValue(FixtureInterface $scope, FlagBag $flags, $value) : ValueInterface
    {
        $uniqueId = sprintf('%s#%s', $scope->getClassName(), $flags->getKey());
        if ('temporary_id' === substr($scope->getId(), 0, 12)) {
            throw DenormalizerExceptionFactory::createForInvalidScopeForUniqueValue();
        }
        if ($value instanceof DynamicArrayValue) {
            $uniqueId = uniqid($uniqueId . '::', true);
            return new DynamicArrayValue($value->getQuantifier(), new UniqueValue($uniqueId, $value->getElement()));
        }
        if ($value instanceof ArrayValue) {
            $uniqueId = uniqid($uniqueId . '::', true);
            $elements = $value->getValue();
            foreach ($elements as $key => $element) {
                // The key must be the same for each argument: the unique ID is bound to the array, not the argument
                // number.
                $elements[$key] = new UniqueValue($uniqueId, $element);
            }
            return new ArrayValue($elements);
        }
        return new UniqueValue($uniqueId, $value);
    }