Doctrineum/Scalar/ScalarEnumType.php
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }
        if (!\is_object($value) || !\is_a($value, ScalarEnumInterface::class)) {
            throw new Exceptions\UnexpectedValueToDatabaseValue(
                'Expected NULL or instance of ' . ScalarEnumInterface::class . ', got ' . ValueDescriber::describe($value)
            );
        }

        return $value->getValue();
    }
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }
        if (!\is_object($value) || !\is_a($value, ScalarEnumInterface::class)) {
            throw new Exceptions\UnexpectedValueToDatabaseValue(
                'Expected NULL or instance of ' . ScalarEnumInterface::class . ', got ' . ValueDescriber::describe($value)
            );
        }

        return $value->getValue();
    }
Convert enum instance to database string (or null) value

@param ScalarEnumInterface $value
@param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
@throws Exceptions\UnexpectedValueToDatabaseValue
@return string|int|float|bool|null