public convertToDatabaseValue ( Dumplie\CustomerService\Domain\PaymentState $value, Doctrine\DBAL\Platforms\AbstractPlatform $platform ) : array | string | ||
$value | Dumplie\CustomerService\Domain\PaymentState | |
$platform | Doctrine\DBAL\Platforms\AbstractPlatform | |
return | array | string |
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (is_null($value)) {
return [];
}
if (!$value instanceof PaymentState) {
throw ConversionException::conversionFailed($value, $this->getName());
}
switch (get_class($value)) {
case PaymentState\Unpaid::class:
return 1;
case PaymentState\Paid::class:
return 2;
case PaymentState\Rejected::class:
return 3;
default:
throw ConversionException::conversionFailed($value, $this->getName());
}
}