Maps given RoleCreateStruct object to a RoleCreateData object.

@param ValueObject|RoleCreateStruct $value

@return RoleCreateData

@throws InvalidArgumentException
327095
public function map(ValueObject $value): RoleCreateData
    {
        if (!$value instanceof RoleCreateStruct) {
            throw new InvalidArgumentException('value', 'must be an instance of ' . RoleCreateStruct::class);
        }

        $data = new RoleCreateData();

        $data->setIdentifier($value->identifier);

        return $data;
    }
1276940
public function addValue($value)
    {
        if ($this->datatype == 'string') {
            if (is_string($value) == false) {
                throw new InvalidArgumentException('The value(' . $value . ') is not string but the restriction demands it');
            }
        } elseif ($this->datatype == 'integer') {
            // The value comes as string from the wsdl
            if (is_string($value)) {
                $value = intval($value);
            }

            if (is_int($value) == false) {
                throw new InvalidArgumentException('The value(' . $value . ') is not int but the restriction demands it');
            }
        } else {
            if ($value == null) {
                throw new InvalidArgumentException('Value(' . $value . ') is null');
            }
        }

        $this->values[] = $value;
    }
619415
protected function checkValueStructure( CoreValue $value )
    {
        if ( !is_array( $value->metas ) )
        {
            throw new InvalidArgumentType(
                '$value->metas',
                'array',
                $value->metas
            );
        }

        foreach ( $value->metas as $index => $meta )
        {
            if ( !$meta instanceof Meta )
            {
                throw new InvalidArgumentType(
                    '$value->metas[' . $index . ']',
                    "\\Novactive\\Bundle\\SEOBundle\\API\\Repository\\Values\\Metas\\Meta",
                    $meta
                );
            }
        }
    }
545263
static function ByValue($value)
    {
        $calledClass = get_called_class();
        $allowed = self::AllowedClassValues($calledClass);
        if (!in_array($value, $allowed, true))
            throw new \InvalidArgumentException('Value ' . $value . ' not allowed for enum ' . $calledClass);
        
        return new $calledClass($value);
    }
580170
public function setRoleType($roleType)
    {
        $allowedValues = $this->getRoleTypeAllowableValues();
        if (!in_array($roleType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'roleType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['roleType'] = $roleType;

        return $this;
    }
930657
protected function createTypeConstraint(Value\ConcreteValueInterface $value)
    {
        if ($value instanceof Value\ArrayValue) {
            $valueTypes = array();
            foreach ($value as $typeValue) {
                $valueTypes[] = Value\ValueType::memberByValue($typeValue->value());
            }

            return new Generic\TypeConstraint($valueTypes);
        }

        return new Generic\TypeConstraint(
            array(Value\ValueType::memberByValue($value->value()))
        );
    }
1364686
public static function Create( $context, $value )
	{
		if ( $value instanceof PathStep )
		{
			return new PathExprNode( $context, $value );
		}

		if ( $value instanceof AbstractNode )
		{
			return $value;
		}

		return new ValueNode( $context, $value );
	}
1287868
public function map(ValueObject $value): RoleUpdateData
    {
        if (!$value instanceof RoleUpdateStruct) {
            throw new InvalidArgumentException('value', 'must be an instance of ' . RoleUpdateStruct::class);
        }

        $data = new RoleUpdateData();

        $data->setIdentifier($value->identifier);

        return $data;
    }
146038
public function newItemCreateStruct(ItemDefinitionInterface $itemDefinition, $value): ItemCreateStruct
    {
        $struct = new ItemCreateStruct();
        $struct->definition = $itemDefinition;
        $struct->value = $value;

        return $struct;
    }
1161907
public function createCreateStructFromRole(Role $role)
    {
        $createStruct = new RoleCreateStruct();

        $createStruct->identifier = $role->identifier;
        $createStruct->policies = $role->policies;

        return $createStruct;
    }
644232
public function add($value)
    {
        if (! $value instanceof SpecificationInterface) {
            throw new InvalidArgumentException(sprintf(
                '"%s" does not implement "%s"!',
                (is_object($value)) ? get_class($value) : $value,
                SpecificationInterface::class
            ));
        }

        return parent::add($value);
    }
230267
protected function createSchema(Value\ObjectValue $value)
    {
        $schema = $this->registeredSchema($value);
        if (null !== $schema) {
            return $schema;
        }

        if ($value->has('default')) {
            $defaultValue = $value->get('default');
        } else {
            $defaultValue = null;
        }

        $schema = new Schema(
            null,
            $defaultValue,
            $value->getRawDefault('title'),
            $value->getRawDefault('description')
        );
        $this->registerSchema($value, $schema);

        $constraints = array();
        foreach ($value as $property => $subValue) {
            $constraints = array_merge(
                $constraints,
                $this->createConstraints($property, $subValue)
            );
        }
        $constraints = array_merge(
            $constraints,
            $this->createCompositeConstraints($value)
        );
        $schema->setConstraints($constraints);

        return $schema;
    }
134246
protected function transformValueContainer(Value\ValueContainerInterface $value)
    {
        if ($this->isVisited($value)) {
            return $value;
        }
        $this->setVisited($value);

        foreach ($value->keys() as $key) {
            if ($value->get($key) instanceof Value\PlaceholderValue) {
                $value->set($key, $value->get($key)->accept($this));
            }
            $value->set($key, $value->get($key)->accept($this));
        }

        return $value;
    }
814424
private function createAttributeValue($name, $value)
    {
        $factory = "create{$name}";

        if ($value instanceof JsonSerializable) {
            $value = $value->jsonSerialize();
        }

        $value = $this->{$factory}($value);

        if (!($value instanceof JsonSerializable || is_array($value))) {
            throw new DomainException('Invalid value factory');
        }

        return $value;
    }
281966
private function structParam($value, StructType $type)
    {
        if (!($value instanceof StructValue) && !is_array($value) && $value !== null) {
            throw new \InvalidArgumentException(
                'Struct value must be an array an instance of `Google\Cloud\Spanner\StructValue` or null.'
            );
        }

        $typeFields = $type->fields();

        // iterate through types and values separately to accurately align
        // unnamed and fields with duplicate names.
        // We also record the original position in order to return values in
        // the order given.
        $values = [];
        if (is_array($value)) {
            $idx = 0;
            foreach ($value as $name => $val) {
                if (!isset($values[$name])) {
                    $values[$name] = [];
                }

                // Nest values inside an array keyed by field name.
                // This allows for duplicate field names, and aligning
                // definitions by position.
                $values[$name][] = [
                    'index' => $idx,
                    'value' => $val
                ];

                $idx++;
            }
        } elseif ($value instanceof StructValue) {
            foreach ($value->values() as $idx => $val) {
                $name = $val['name'];
                $valValue = $val['value'];

                if (!isset($values[$name])) {
                    $values[$name] = [];
                }

                $values[$name][] = [
                    'index' => $idx,
                    'value' => $valValue
                ];
            }
        }

        // Iterate through given type fields and align them with corresponding values.
        $res = [];
        $fields = [];
        $names = [];
        foreach ($typeFields as $typeIndex => $paramType) {
            $fieldName = $paramType['name'];

            // Count the number of times the field name has been encountered thus far.
            // This lets us pick the correct index for duplicate fields.
            if (isset($names[$fieldName])) {
                $names[$fieldName]++;
            } else {
                $names[$fieldName] = 0;
            }

            // Get the value which corresponds to the current type.
            $index = $names[$fieldName];
            $paramValue = isset($values[$fieldName][$index])
                ? $values[$fieldName][$index]
                : null;

            // If the value didn't exist in the values structure, set it to null.
            // The $typeIndex will give us a hook to order fields properly.
            // Otherwise, remove the current field value from the list of values.
            if ($paramValue === null) {
                $paramValue = ['value' => null, 'index' => $typeIndex];
            } else {
                unset($values[$fieldName][$index]);
            }

            $param = $this->paramType($paramValue['value'], $paramType['type'], $paramType['child']);

            $fields[$paramValue['index']] = array_filter([
                'name' => $fieldName,
                'type' => $param[1]
            ]);

            $res[$paramValue['index']] = $param[0];
        }

        // Iterate over any remaining fields. If anything is left here, it means
        // no type was defined and its type must be inferred.
        foreach ($values as $name => $list) {
            foreach ($list as $value) {
                $index = $value['index'];
                $val = $value['value'];

                $type = null;
                $def = null;
                if (is_array($val) && !$this->isAssoc($val)) {
                    $type = Database::TYPE_ARRAY;
                    $def = new ArrayType(null);
                }

                $param = $this->paramType($val, $type, $def);

                $fields[$index] = array_filter([
                    'name' => $name,
                    'type' => $param[1]
                ]);

                $res[$index] = $param[0];
            }
        }

        // Sort values and fields by key to reset back to the order given by the user.
        ksort($res);
        ksort($fields);

        $type = [
            'code' => self::TYPE_STRUCT,
            'structType' => [
                'fields' => $fields
            ]
        ];

        // If the input is null, send null (but with the full type structure)
        $res = $value === null ? null : $res;

        return [
            $res,
            $type
        ];
    }
1109954
public function createObjectType() : ObjectConstructorCallbackDefiner
    {
        return new ObjectConstructorCallbackDefiner($this->class, function (callable $typeCallback) {
            $this->createObjectCallback = function (array $input) use ($typeCallback) {
                $className = $this->class->getClassName();

                /** @var ValueObject $valueObject */
                $valueObject = $typeCallback($input);

                if (!($valueObject instanceof $className)) {
                    throw InvalidReturnValueException::format(
                        'Invalid create object callback return value: expecting class compatible with %s, %s given',
                        $className, is_string($valueObject) ? $valueObject : Debug::getType($valueObject)
                    );
                }

                return $valueObject;
            };
        });
    }
1064796
protected function handleStructParameter( $value )
    {
        $values = array();
        foreach ( $value->member as $value )
        {
            $values[(string)$value->name] = $this->processParameter( (array)$value->value );
        }

        return $values;
    }