Dumplie\CustomerService\Infrastructure\Doctrine\ORM\Type\Domain\OrderStateType::convertToDatabaseValue PHP Method

convertToDatabaseValue() public method

public convertToDatabaseValue ( Dumplie\CustomerService\Domain\OrderState $value, Doctrine\DBAL\Platforms\AbstractPlatform $platform ) : array | string
$value Dumplie\CustomerService\Domain\OrderState
$platform Doctrine\DBAL\Platforms\AbstractPlatform
return array | string
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (is_null($value)) {
            return [];
        }
        if (!$value instanceof OrderState) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }
        switch (get_class($value)) {
            case OrderState\Accepted::class:
                return 1;
            case OrderState\Created::class:
                return 2;
            case OrderState\Prepared::class:
                return 3;
            case OrderState\Refunded::class:
                return 4;
            case OrderState\Rejected::class:
                return 5;
            case OrderState\Sent::class:
                return 6;
            default:
                throw ConversionException::conversionFailed($value, $this->getName());
        }
    }