{@inheritdoc}

@throws \Fridge\DBAL\Exception\PlatformException If the mapped type does not exist.
@throws \Fridge\DBAL\Exception\TypeException     If the type does not exist.
335609
public function overrideMappedType($databaseType, $fridgeType)
    {
        if (!$this->hasMappedType($databaseType)) {
            throw PlatformException::mappedTypeDoesNotExist($databaseType);
        }

        if (!Type::hasType($fridgeType)) {
            throw TypeException::typeDoesNotExist($fridgeType);
        }

        $this->mappedTypes[$databaseType] = $fridgeType;
    }
775882
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return ($this->serializer)($value, $this->name, $platform);
    }
302870
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return null;
        }

        if (ctype_alpha($value[0])) {
            return $this->getSpatialPlatform($platform)->convertStringToPHPValue($this, $value);
        }

        return $this->getSpatialPlatform($platform)->convertBinaryToPHPValue($this, $value);
    }
618200
private function getSpatialPlatform(AbstractPlatform $platform)
    {
        $const = sprintf('self::PLATFORM_%s', strtoupper($platform->getName()));

        if (! defined($const)) {
            throw new UnsupportedPlatformException(sprintf('DBAL platform "%s" is not currently supported.', $platform->getName()));
        }

        $class = sprintf('CrEOF\Spatial\DBAL\Platform\%s', constant($const));

        return new $class;
    }
456976
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof UuidInterface) {
            return $value->getBytes();
        }

        try {
            if (is_string($value) || method_exists($value, '__toString')) {
                return Uuid::fromString((string) $value)->getBytes();
            }
        } catch (InvalidArgumentException $e) {
            // Ignore the exception and pass through.
        }

        throw ConversionException::conversionFailed($value, static::NAME);
    }
170546
public function mapPriceType($priceType)
    {

        // query whether or not the passed price type is available
        if (isset($this->priceTypeMapping[$priceType])) {
            return $this->priceTypeMapping[$priceType];
        }

        // throw an exception, if not
        throw new \Exception(
            $this->appendExceptionSuffix(
                sprintf('Can\'t find mapping for price type %s', $priceType)
            )
        );
    }
744029
private function resolveDatabaseType($type)
    {
        foreach ($this->getDatabases() as $database) {
            if ($database->type === $type) {
                return $database;
            }
        }
        throw new \DomainException(sprintf('Unknown database type (%s). Please use mysqli, pgsql or mariadb.', $type));
    }
1125128
public function toResource(EntityInterface $entity, FetchRequestInterface $request, ResourceInterface $resource)
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                $this->configureResourceMapper($mapper);
                $mapper->toResource($entity, $request, $resource);

                return;
            }
        }

        throw new UnsupportedTypeException($resource->type());
    }
1343103
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if (
            $value instanceof UuidInterface
            || (
                (is_string($value) || method_exists($value, '__toString'))
                && Uuid::isValid((string) $value)
            )
        ) {
            return (string) $value;
        }

        throw ConversionException::conversionFailed($value, static::NAME);
    }
859613
public function convertToDatabaseValueSql($value, AbstractPlatform $platform)
    {
        return parent::convertToDatabaseValueSQL($value instanceof ModelInterface ? $value->pk : $value, $platform);
    }
330790
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

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

        try {
            return $this->decode($value);
        } catch (InvalidArgumentException $e) {
            throw ConversionException::conversionFailed($value, self::NAME);
        }
    }
755631
public static function getType($type)
    {
        if (!isset(static::$mappedTypeInstances[$type])) {
            if (!static::hasType($type)) {
                throw TypeException::typeDoesNotExist($type);
            }

            static::$mappedTypeInstances[$type] = new static::$mappedTypeClasses[$type]();
        }

        return static::$mappedTypeInstances[$type];
    }
30094
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

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

        try {
            $uuid = Uuid::fromBytes($value);
        } catch (InvalidArgumentException $e) {
            throw ConversionException::conversionFailed($value, static::NAME);
        }

        return $uuid;
    }
787039
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return;
        }

        $val = \DateTime::createFromFormat(
            $platform->getDateTimeFormatString(),
            $value,
            new \DateTimeZone('UTC')
        );
        if (!$val) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }

        return $val;
    }
325471
protected function convertParam($platform, $param, $type = null)
    {
        if (is_object($param)) {
            if (!method_exists($param, '__toString')) {
                if ($param instanceof DateTimeInterface) {
                    $param = $param->format('Y-m-d H:i:s');
                } elseif (Type::hasType($type)) {
                    $type  = Type::getType($type);
                    $param = $type->convertToDatabaseValue($param, $platform);
                } else {
                    throw new Exception('Given query param is an instance of ' . get_class($param) . ' and could not be converted to a string');
                }
            }
        } elseif (is_array($param)) {
            if ($this->isNestedArray($param)) {
                $param = json_encode($param, JSON_UNESCAPED_UNICODE);
            } else {
                $param = implode(
                    ', ',
                    array_map(
                        function ($part) {
                            return '"' . (string) $part . '"';
                        },
                        $param
                    )
                );

                return '(' . $param . ')';
            }
        } else {
            $param = e($param);
        }

        return '"' . (string) $param . '"';
    }
970197
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof Uuid || Uuid::isValid($value)) {
            return (string) $value;
        }

        throw ConversionException::conversionFailed($value, self::NAME);
    }
411669
protected function processSelect(
        PlatformInterface $platform,
        DriverInterface $driver = null,
        ParameterContainer $parameterContainer = null
    ) {
        $expr = 1;

        // process table columns
        $columns = [];
        foreach ($this->columns as $columnIndexOrAs => $column) {

            $colName = '';
            if ($column === self::SQL_STAR) {
                $columns[] = [self::SQL_STAR]; // Sphinx doesn't not support prefix column with table, yet
                continue;
            }

            if ($column instanceof Expression) {
                $columnParts = $this->processExpression(
                    $column,
                    $platform,
                    $driver,
                    $parameterContainer,
                    $this->processInfo['paramPrefix'] . ((is_string($columnIndexOrAs)) ? $columnIndexOrAs : 'column')
                );
                $colName .= $columnParts;
            } else {
                // Sphinx doesn't not support prefix column with table, yet
                $colName .= $platform->quoteIdentifier($column);
            }

            // process As portion
            $columnAs = null;
            if (is_string($columnIndexOrAs)) {
                $columnAs = $columnIndexOrAs;
            } elseif (stripos($colName, ' as ') === false && !is_string($column)) {
                $columnAs = 'Expression' . $expr++;
            }

            $columns[] = isset($columnAs) ? [$colName, $platform->quoteIdentifier($columnAs)] : [$colName];
        }

        if ($this->table) {
            $tableList = $this->table;

            if (is_string($tableList) && strpos($tableList, ',') !== false) {
                $tableList = preg_split('#,\s+#', $tableList);
            } elseif (!is_array($tableList)) {
                $tableList = [$tableList];
            }

            foreach ($tableList as &$table) {

                // create quoted table name to use in FROM clause
                if ($table instanceof Select) {
                    $table = '(' . $this->processSubselect($table, $platform, $driver, $parameterContainer) . ')';
                } else {
                    $table = $platform->quoteIdentifier($table);
                }
            }

            $tableList = implode(', ', $tableList);

            return [$columns, $tableList];
        }

        return [$columns];
    }