From database to object.

@param string $value

@return mixed
320089
public function unserialize($value)
    {
        $type = $this->getDataType();

        if ($type === 'json') {
            $value = json_decode($value, true);
        } elseif ($type === 'array') {
            $value = json_decode($value, true);
        } elseif ($type === 'list') {
            $value = explode(',', $value);
        } elseif ($type === 'boolean') {
            $value = (bool) $value;
        } elseif ($type === 'integer') {
            if (strlen($value)) {
                $value = (int) $value;
            } else {
                $value = null;
            }
        } elseif ($type === 'float') {
            if (strlen($value)) {
                $value = (float) $value;
            } else {
                $value = null;
            }
        }

        return $value;
    }
1161264
protected function unserialize($value)
    {
        if ($this->connection instanceof PostgresConnection && ! Str::contains($value, [':', ';'])) {
            $value = base64_decode($value);
        }

        return unserialize($value);
    }
225760
public static function FromValue( $value )
	{
		if ( is_string( $value ) && ( ! is_numeric( $value ) || ( ! is_int( $value + 0 ) && is_double( $value + 0 ) ) ) )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "integer" ) );
		}

		if ( is_numeric( $value ) )
		{
			if ( is_infinite( $value ) )
				throw XPath2Exception::withErrorCodeAndParams( "FOAR0001", Resources::FOAR0001, array( $value, "integer" ) );

			if ( $value > PHP_INT_MAX || $value < PHP_INT_MIN )
				throw XPath2Exception::withErrorCodeAndParams( "FOAR0002", Resources::FOAR0002, array( $value, "integer" ) );
		}

		return new Integer( $value );
	}
804045
protected function deep_clone($value) {
        if (is_object($value)) {
            // Objects must be cloned to begin with.
            $value = clone $value;
        }
        if (is_array($value) || is_object($value)) {
            foreach ($value as $key => $subvalue) {
                $value[$key] = $this->deep_clone($subvalue);
            }
        }
        return $value;
    }
918689
protected function valueRetriever($value)
	{
		return function($item) use ($value)
		{
			return is_object($item) ? $item->{$value} : array_get($item, $value);
		};
	}
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
143494
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value || '' === $value) {
            return $value;
        }

        if ( ! $value instanceof Money) {
            $type = is_object($value) ? get_class($value) : gettype($value);
            throw new \InvalidArgumentException(sprintf('You have to pass an object of kind \SerendipityHQ\Component\ValueObjects\Money\Money to use the Doctrine type MoneyType. "%s" passed instead.', $type));
        }

        return $value->getBaseAmount() . '-' . $value->getCurrency()->getCode();
    }
293454
public function convertToDatabaseValue($value, AbstractPlatform $platform)
	{
		if (is_null($value)) {
			return null;
		}
		
		$string = $value->getFullPath();
		
		return $string;
	}
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;
    }
775882
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return ($this->serializer)($value, $this->name, $platform);
    }
132047
protected function transformObject($value)
    {
        if (!is_object($value)) {
            return;
        }

        // If a toJson() method exists, we'll assume that
        // the object can cast itself automatically.
        if (method_exists($value, 'toJson')) {
            return $value->toJson();
        }

        if ($value instanceof JsonSerializable || $value instanceof stdClass || $value instanceof Arrayable) {
            return json_encode($value);
        }

        // Otherwise, if the object doesn't even have a
        // __toString() method, we can't proceed.
        if (!method_exists($value, '__toString')) {
            throw new Exception('Cannot transform this object to JavaScript.');
        }

        return "'{$value}'";
    }
81817
public static function decode(string $value)
    {
        $stdObject = json_decode($value);
        // catch error if it occurs
        self::catchError();

        if (self::getError()) {
            return self::getError();
        }

        return $stdObject;
    }
279860
protected function createValue(&$value)
    {
        $instance = $this->instance($value);
        if (null !== $instance) {
            return $instance;
        }

        $variableType = gettype($value);
        switch ($variableType) {
            case 'boolean':
                return new Value\BooleanValue($value);
            case 'integer':
                return new Value\IntegerValue($value);
            case 'double':
                return new Value\FloatingPointValue($value);
            case 'NULL':
                return new Value\NullValue;
            case 'string':
                return new Value\StringValue($value);
            case 'array':
                return $this->createArray($value);
            case 'object':
                if ($value instanceof DateTime) {
                    return new Value\DateTimeValue($value);
                }

                return $this->createObject($value);
        }

        throw new Exception\UnsupportedValueTypeException($value);
    }
671014
public function fromDateTime($value)
    {
        $format = $this->getDateFormat();

        $value = $this->asDateTime($value);

        return $value->format($format);
    }
345162
protected function serializeValue($value)
    {
        $serialized = var_export($value, true);
        if ($serialized === 'NULL') {
            $serialized = strtolower($serialized);
        }

        return $serialized;
    }
87414
public static function fromValue($value)
    {
        foreach (static::values() as $key => $enumInstance) {
            if ($enumInstance->getValue() === $value) {
                return $enumInstance;
            }
        }

        return null;
    }
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);
    }