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
|
|
|
|
2023-07-21 10:35:15 -04:00
|
|
|
class MoneyType extends Type {
|
|
|
|
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
|
|
|
|
{
|
|
|
|
return 'MONEY';
|
|
|
|
}
|
2022-03-03 10:53:48 -05:00
|
|
|
|
2023-07-21 10:35:15 -04:00
|
|
|
public function convertToPHPValue($value, AbstractPlatform $platform): float
|
|
|
|
{
|
|
|
|
return (float) (string) new Money($value);
|
|
|
|
}
|
2022-03-03 10:53:48 -05:00
|
|
|
|
2023-07-21 10:35:15 -04:00
|
|
|
public function getName(): string
|
|
|
|
{
|
|
|
|
return 'money';
|
|
|
|
}
|
2022-03-03 10:53:48 -05:00
|
|
|
|
2023-07-21 10:35:15 -04:00
|
|
|
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-02-14 15:08:03 -05:00
|
|
|
}
|