Maps a value coming from BigQuery to the expected format for use in the
library.

@param array $value The value to map.
@param array $schema The schema describing the value.
@throws \InvalidArgumentException
559233
public function fromBigQuery(array $value, array $schema)
    {
        $value = $value['v'];

        if (isset($schema['mode'])) {
            if ($schema['mode'] === 'REPEATED') {
                return $this->repeatedValueFromBigQuery($value, $schema);
            }

            if ($schema['mode'] === 'NULLABLE' && $value === null) {
                return $value;
            }
        }

        switch ($schema['type']) {
            case self::TYPE_BOOLEAN:
                return $value === 'true';
            case self::TYPE_INTEGER:
                return $this->returnInt64AsObject
                    ? new Int64($value)
                    : (int) $value;
            case self::TYPE_FLOAT:
                return (float) $value;
            case self::TYPE_NUMERIC:
                return new Numeric($value);
            case self::TYPE_STRING:
                return (string) $value;
            case self::TYPE_BYTES:
                return new Bytes(base64_decode($value));
            case self::TYPE_DATE:
                return new Date(new \DateTime($value));
            case self::TYPE_DATETIME:
                return new \DateTime($value);
            case self::TYPE_TIME:
                return new Time(new \DateTime($value));
            case self::TYPE_TIMESTAMP:
                return $this->timestampFromBigQuery($value);
            case self::TYPE_RECORD:
                return $this->recordFromBigQuery($value, $schema['fields']);
            default:
                throw new \InvalidArgumentException(sprintf(
                    'Unrecognized value type %s. Please ensure you are using the latest version of google/cloud.',
                    $schema['type']
                ));

                break;
        }
    }
664213
public function addParam($name, $value, $convertToArrayIfExists = false)
    {
        if (isset($this->components[self::QUERY][$name])) {
            if (!is_array($this->components[self::QUERY][$name])) {
                if ($convertToArrayIfExists) {
                    $this->components[self::QUERY][$name] = [$this->components[self::QUERY][$name]];
                } else {
                    throw new \InvalidArgumentException("$name is not an array");
                }
            }
        } else {
            $this->components[self::QUERY][$name] = [];
        }
        $this->components[self::QUERY][$name][] = $value;
        return $this;
    }
1357856
protected function applyCallback(stdClass $schema): stdClass
    {
        if (is_callable($this->callback)) {
            $result = call_user_func_array($this->callback, [Convert::objectToArray($schema)]);

            if (is_null($result)) {
                throw new InvalidArgumentException('Callback returned `null`. Did you forget to `return $schema;`?');
            }

            if ($result !== false) {
                return Convert::arrayToObject($result);
            }
        }

        return $schema;
    }
1148928
public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
    {
        if (!$definition instanceof AssociationFieldDefinition) {
            throw DoctrineStorageException::invalidDefinition(AssociationFieldDefinition::class, $definition);
        }

        $table->addColumn(
            $name,
            'guid',
            [
                'notnull' => !$definition->isNullable(),
                'default' => $definition->defaultValue(),
                'length' => $definition->options()['length'] ?? null,
                'unique' => $definition->options()['unique'] ?? false,
            ]
        );

        $table->addForeignKeyConstraint(
            $this->tableName($schema, $definition->typeSchema()->name()),
            [$name],
            ['id']
        );
    }
200688
public function setValue($value)
    {
        if ('checkbox' === $this->type && false === $value) {
            // uncheck
            $this->value = null;
        } elseif ('checkbox' === $this->type && true === $value) {
            // check
            $this->value = $this->options[0]['value'];
        } else {
            if (is_array($value)) {
                if (!$this->multiple) {
                    throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
                }

                foreach ($value as $v) {
                    if (!$this->containsOption($v, $this->options)) {
                        throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->availableOptionValues())));
                    }
                }
            } elseif (!$this->containsOption($value, $this->options)) {
                throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->availableOptionValues())));
            }

            if ($this->multiple) {
                $value = (array) $value;
            }

            if (is_array($value)) {
                $this->value = $value;
            } else {
                parent::setValue($value);
            }
        }
    }
1363186
public function setSchema($schema)
    {
        if (!\is_string($schema) && !$schema instanceof SchemaDefinitionInterface) {
            throw new InvalidSchemaDefinitionException();
        }

        $this->schema = $schema;
    }
870381
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $categories = array_values(array_unique($values));

        $this->categories = $categories;
        $this->k = count($categories);
    }
854716
public function offsetSet($offset, $value): void
    {
        if (false === $this->checkType($this->getKeyType(), $offset)) {
            throw new InvalidArgumentException(
                'Key must be of type ' . $this->getKeyType() . '; key is '
                . $this->toolValueToString($offset)
            );
        }

        if (false === $this->checkType($this->getValueType(), $value)) {
            throw new InvalidArgumentException(
                'Value must be of type ' . $this->getValueType() . '; value is '
                . $this->toolValueToString($value)
            );
        }

        parent::offsetSet($offset, $value);
    }
1294713
public function setAttributes($values){

        if(is_array($values)){
            foreach($values as $name => $value){
                $this->setAttribute($name, $value);
            }
        }else{
            throw new InvalidArgumentException('"values" must be an array');
        }

    }
1302625
protected function validateSchema($schema)
    {
        if (!is_string($schema) || trim($schema) == '') {
            throw new Exception\InvalidArgumentException(__METHOD__ . ': Schema name must be a valid string or an empty string detected');
        }

        return $this;
    }
1314258
public function setValueAttribute($value)
    {
        if (!$this->isValid($value)) {
            throw new InvalidValueException("The value in the field '" . get_class($this) . "' is invalid");
        }

        $this->attributes['value'] = $this->prepareValue($value);
    }
478797
public static function type($value, $choices, $keyword, $pointer)
    {
        $actualType = gettype($value);
        $choices    = is_array($choices)  ? $choices : [$choices];

        if (in_array($actualType, $choices) ||
            (is_json_number($value) && in_array('number', $choices))) {
            return;
        }

        throw InvalidSchemaException::invalidParameterType(
            $actualType,
            $choices,
            $keyword,
            $pointer
        );
    }
879201
protected function generateDataTypes(array $schema)
    {
        $directory = $this->getMappingDirectory('DataType');
        foreach ($schema['datatypes'] as $dataType => $data) {
            $this->generateDataType($dataType, $data, $directory);
        }
    }
836144
public function resolveBind($field, $value, array $schema = []) {
        $type = null;

        // Exit early for functions since we don't have a valid field
        if ($field instanceof Func) {
            return [$value, $this->resolveType($value)];
        }

        // Use the raw value for binding
        if ($value instanceof RawExpr) {
            $value = $value->getValue();
        }

        // Type cast
        if ($value === null) {
            $type = PDO::PARAM_NULL;

        } else if (isset($schema[$field]['type'])) {
            $dataType = $this->getType($schema[$field]['type']);
            $value = $dataType->to($value);
            $type = $dataType->getBindingType();
        }

        // Fallback and resolve
        if (!$type) {
            $type = $this->resolveType($value);
        }

        return [$value, $type];
    }
796296
public function set(string $path, array &$row, string $value = null): void
    {
        if (!$this->supports($row)) {
            return;
        }
        if (!array_key_exists($this->colName, $row)) {
            $row[$this->colName] = [];
        }

        $content = &$row[$this->colName];
        $chunks  = explode('.', $path);
        if (!array_key_exists($chunks[0], $content)) {
            $content[$chunks[0]] = [];
        }
        $content = &$content[$chunks[0]];

        if (null === ($extractor = $this->extractors[$chunks[1]] ?? null)) {
            throw new \InvalidArgumentException('Sub extractor ' . $chunks[1] . ' not found');
        }

        switch (true) {
            case $extractor instanceof MultiStringExtractorInterface:
                $extractor->set(implode('.', \array_slice($chunks, 2)), $content, $value);
                return;
            case $extractor instanceof StringExtractorInterface:
                $extractor->set($content, $value);
                return;
            default:
        }

        throw new \InvalidArgumentException('Unknown extractor type ' . \get_class($extractor));
    }
112245
public function set($key, $value)
    {
        if (is_array($key) && $value === null)
            $args = $key;
        else
            $args = func_get_args();

        $value = array_pop($args);
        
        $parent = null;
        $key = null;
        $ref = &$this->values;
        foreach ($args as $arg)
        {
            if (!is_scalar($arg))
                throw new \InvalidArgumentException("Keys must be scalar, not: " . WF::str($arg));

            if (!is_array($ref))
            {
                if ($parent !== null)
                    $parent[$key] = array();
                $ref = &$parent[$key];
            }
                
            if (!isset($ref[$arg]))
                $ref[$arg] = array();

            $parent = &$ref;
            $key = $arg;
            $ref = &$ref[$arg];
        }

        // Unwrap Dictionary objects
        $cl = is_object($value) ? get_class($value) : null;
        if ($cl === Dictionary::class)
            $ref = $value->getAll();
        else
            $ref = $value;

        return $this;
    }
139565
public function setValue($value)
    {
        if (null !== $value) {
            if (!$this->validateValue($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Binding invalid value (type "%s") into filter "%s" (%s)',
                    \is_object($value) ? \get_class($value) : \gettype($value),
                    $this->name,
                    \get_class($this)
                ));
            }

            $this->value = $value;
            $this->updateBound();
        }

        return $this;
    }