BigIntType.php
2 months ago
DateTimeTzToStringType.php
3 years ago
JsonOrSerializedType.php
2 months ago
JsonType.php
2 months ago
SerializedArrayType.php
2 months ago
index.php
3 years ago
BigIntType.php
36 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Doctrine\Types; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoetVendor\Doctrine\DBAL\ParameterType; |
| 9 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 10 | use MailPoetVendor\Doctrine\DBAL\Types\BigIntType as DoctrineBigIntType; |
| 11 | |
| 12 | class BigIntType extends DoctrineBigIntType { |
| 13 | // override Doctrine's bigint type that historically maps DB's "bigint" to PHP's "string" |
| 14 | // (we want to map DB's "bigint" to PHP's "int" in today's 64-bit world) |
| 15 | const NAME = 'bigint'; |
| 16 | |
| 17 | public function getBindingType() { |
| 18 | return ParameterType::INTEGER; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @param mixed $value |
| 23 | * @return int|null |
| 24 | */ |
| 25 | public function convertToPHPValue($value, AbstractPlatform $platform) { |
| 26 | if ($value === null) { |
| 27 | return null; |
| 28 | } |
| 29 | return is_numeric($value) ? (int)$value : 0; |
| 30 | } |
| 31 | |
| 32 | public function getName() { |
| 33 | return self::NAME; |
| 34 | } |
| 35 | } |
| 36 |