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
DateTimeTzToStringType.php
33 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\Carbon\Carbon; |
| 9 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 10 | use MailPoetVendor\Doctrine\DBAL\Types\DateTimeTzType; |
| 11 | |
| 12 | class DateTimeTzToStringType extends DateTimeTzType { |
| 13 | const NAME = 'datetimetz_to_string'; |
| 14 | |
| 15 | public function convertToPHPValue($value, AbstractPlatform $platform) { |
| 16 | $dateTime = parent::convertToPHPValue($value, $platform); |
| 17 | |
| 18 | if (!$dateTime) { |
| 19 | return $dateTime; |
| 20 | } |
| 21 | |
| 22 | return Carbon::instance($dateTime); |
| 23 | } |
| 24 | |
| 25 | public function requiresSQLCommentHint(AbstractPlatform $platform): bool { |
| 26 | return true; |
| 27 | } |
| 28 | |
| 29 | public function getName(): string { |
| 30 | return self::NAME; |
| 31 | } |
| 32 | } |
| 33 |