Maps a user provided value to the expected BigQuery format.

@param mixed $value The value to map.
@return mixed
507833
public function toBigQuery($value)
    {
        if ($value instanceof ValueInterface || $value instanceof Int64) {
            return (string) $value;
        }

        if ($value instanceof \DateTime) {
            return $value->format(self::DATETIME_FORMAT_INSERT);
        }

        if (is_array($value)) {
            foreach ($value as $key => $item) {
                $value[$key] = $this->toBigQuery($item);
            }

            return $value;
        }

        return $value;
    }
1239422
protected function formatValue($value)
    {
        // If the value is a date we'll format it according to the specified
        // date format.
        if ($value instanceof DateTime || $value instanceof Carbon)
        {
            $value = $value->format($this->grammar->getDateFormat());
        }

        return $value;
    }
1248942
protected function wrapValue($value)
    {
        if ($value === '*') {
            return $value;
        }

        // If querying hstore
        if (preg_match('/\[(.*?)\]/', $value, $match)) {
            return (string)str_replace(array('[', ']'), '', $match[1]);
        }

        // If querying json column
        foreach ($this->jsonOperators as $operator) {
            if (stripos($value, $operator)) {
                list($value, $key) = explode($operator, $value, 2);
                return parent::wrapValue($value) . $operator . $key;
            }
        }

        return parent::wrapValue($value);
    }
252131
public function filter($value)
    {
        if ($this->toEncoding === null) {
            return $value;
        }

        if ($this->fromEncoding === null) {
            return mb_convert_encoding($value, $this->toEncoding);
        }

        return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding);
    }
1338137
public static function serializeValue($value)
    {
        if ($value instanceof JsonSerializable || $value instanceof \JsonSerializable) {
            return $value->jsonSerialize();
        }

        if (is_object($value)) {
            foreach (get_object_vars($value) as $nestedKey => $nestedValue) {
                $value->{$nestedKey} = self::serializeValue($nestedValue);
            }

            return $value;
        }

        if (is_array($value)) {
            foreach ($value as &$nestedValue) {
                $nestedValue = self::serializeValue($nestedValue);
            }

            return $value;
        }

        if ($value instanceof DateTime || $value instanceof \DateTimeInterface) {
            throw new DomainException('Please wrap your DateTime objects with Aplazame\Serializer\Date::fromDateTime');
        }

        if (is_float($value)) {
            throw new DomainException('Please wrap your float values with Aplazame\Serializer\Decimal::fromFloat');
        }

        return $value;
    }
214494
public static function convertToDb($value)
    {
        if (!is_array($value)) {
            return [];
        }

        // see DateType::convertToDatabaseValue()
        $convertor = function ($value) {
            if ($value === null || $value instanceof \MongoDate) {
                return $value;
            }

            try {
                $datetime = DateType::getDateTime($value);
                return new \MongoDate($datetime->format('U'), $datetime->format('u'));
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        };

        return array_values(array_filter(array_map($convertor, $value)));
    }
1042997
public static function prepareToStore($value)
    {
        // if array - try to prepare every value
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = self::prepareToStore($v);
            }

            return $value;
        }

        // if scalar - return it
        if (!is_object($value)) {
            return $value;
        }

        // if internal mongo types - pass it as is
        if (TypeChecker::isInternalType($value)) {
            return $value;
        }

        // do not convert geo-json to array
        if ($value instanceof Geometry) {
            return $value->jsonSerialize();
        }

        // structure
        if ($value instanceof Structure) {
            // validate structure
            if (!$value->isValid()) {
                $exception = new InvalidDocumentException('Embedded document not valid');
                $exception->setDocument($value);
                throw $exception;
            }

            // get array from structure
            return $value->toArray();
        }

        // other objects convert to array
        return (array) $value;
    }
1371583
public function convertToDatabaseValue ($value, AbstractPlatform $platform) {
		if ($value === null) {
			return null;
		}

		$value -> setTimezone(self::getUTCTimeZone());
		return $value -> format($platform -> getDateTimeFormatString());
	}
741480
public function withTransformations($value) {
        // null for not provided remains untouched
        if ($value === null)
            return null;

        foreach ($this->valueTransformations as $f)
            $value = $f($value);

        return $value;
    }
11290
public function entities($value)
    {
        if (is_array($value)) {
            $newValue = array();
            foreach ($value as $key => $val) {
                $newValue[$key] = htmlentities($val, ENT_QUOTES, 'UTF-8', false);
            }

            return $newValue;
        }

        return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
    }
1352943
public function serialize($value) {
        if ($value instanceof SerializablePersonalDataValue) {
            return $this->serializePersonalDataValue($value);
        } elseif ($value instanceof SerializableValue) {
            return $this->serializeValue($value);
        }
        return $value;
    }
681628
private function serializeValue($value)
    {
        if (is_object($value)) {
            return $this->serializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->serializeArrayRecursively($value);
        }

        return $value;
    }
4258
public function convertQueryCondition($value)
    {
        // First fetch the type
        if (null === $value) {
            return 0;
        }

        if (!is_array($value)) {
            $value = [$value];
        }

        $hasOperator = false;

        // FIXME Sorry for this
        if (!Misc::isIndexed($value)) {
            // We have an operator.
            $operator = array_keys($value)[0];
            $values = $value[$operator][0];
            $hasOperator = true;
        } else {
            $values = $value;
        }

        foreach ($values as $key => $type) {
            if (null === $type) {
                $values[$key] = 0;
            } else if ($typeId = $this->getTypeId($type, false)) {
                $values[$key] = $typeId;
            } else {
                unset($values[$key]);
            }
        }

        if (empty($values)) {
            // It should not have been empty, this is an impossible
            // condition
            $values = [-1];
        }

        if ($hasOperator) {
            return [$operator => $values];
        } else {
            return $values;
        }
    }
1369779
public function serialize($value)
    {
        $this->noMappingGuard();

        if (\is_array($value) && !empty($value[Serializer::MAP_TYPE])) {
            $data = $this->serializedArray($value);
        } else {
            $data = $this->serializeObject($value);
        }

        return \json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    }
1373038
public function dbTypecastValue($value)
    {
        if ($value === null) {
            return null;
        }

        switch ($this->type) {
            case Schema::TYPE_BIT:
                return decbin($value);
            case Schema::TYPE_BINARY:
                return is_string($value) ? new PdoValue($value, \PDO::PARAM_LOB) : $value;
            case Schema::TYPE_TIMESTAMP:
            case Schema::TYPE_DATETIME:
                return \Yii::$app->formatter->asDatetime($value, 'yyyy-MM-dd HH:mm:ss');
            case Schema::TYPE_DATE:
                return \Yii::$app->formatter->asDate($value, 'yyyy-MM-dd');
            case Schema::TYPE_TIME:
                return \Yii::$app->formatter->asTime($value, 'HH:mm:ss');
            case Schema::TYPE_JSON:
                return new JsonExpression($value, $this->dbType);
            case Schema::TYPE_COMPOSITE:
                return new CompositeExpression($value, $this->dbType, $this);
        }

        return $this->typecast($value);
    }
428167
protected function prepareValue($value)
    {
        $params = $this->getOperatorParams();
        $method = $params['method'];
        switch ($method) {
            case 'where':
            case 'whereNull':
            case 'whereNotNull':
                break;
            case 'whereBetween':
            case 'whereNotBetween':
                if (! is_array($value)) {
                    $value = explode(',', $value, 2);
                }
                break;
            case 'whereIn':
            case 'whereNotIn':
                if (! is_array($value)) {
                    $value = explode(',', $value);
                }
                break;
        }

        return $value;
    }
621884
protected function mapInfoForValue($value) {
		if ($this->processor->startsWith($value, '\'') && $this->processor->endsWith($value, '\'')) {
			return ['around' => '\''];
		}

		if ($this->processor->startsWith($value, '"') && $this->processor->endsWith($value, '"')) {
			return ['around' => '"'];
		}
	}