2022-02-18 11:34:25 -05:00
|
|
|
<?php declare(strict_types=1);
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
namespace App\Types;
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
use App\ValueObject\Money;
|
2022-03-03 10:53:48 -05:00
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2022-03-03 10:53:48 -05:00
|
|
|
use Doctrine\DBAL\Types\Type;
|
2019-07-23 10:31:06 -04:00
|
|
|
|
2022-03-03 10:53:48 -05:00
|
|
|
class MoneyType extends Type
|
|
|
|
{
|
|
|
|
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
|
|
|
|
{
|
|
|
|
return 'MONEY';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function convertToPHPValue($value, AbstractPlatform $platform): float
|
|
|
|
{
|
|
|
|
return (float) (string) new Money($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string
|
|
|
|
{
|
|
|
|
return 'money';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
|
|
|
|
{
|
2022-03-03 11:15:12 -05:00
|
|
|
return TRUE;
|
2022-03-03 10:53:48 -05:00
|
|
|
}
|
2018-02-14 15:08:03 -05:00
|
|
|
}
|