| Total Complexity | 8 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 9 | class DateTimeMicroType extends Type |
||
| 10 | { |
||
| 11 | const NAME = 'datetime_micro'; |
||
| 12 | |||
| 13 | const FORMAT = 'Y-m-d H:i:s.u'; |
||
| 14 | |||
| 15 | public function getName(): string |
||
| 16 | { |
||
| 17 | return self::NAME; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string |
||
| 21 | { |
||
| 22 | return "DATETIME(6) COMMENT '(DC2Type:" . self::NAME . ")'"; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** @param \DateTime|null $value */ |
||
| 26 | public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string |
||
| 27 | { |
||
| 28 | return ($value !== null) ? $value->format(self::FORMAT) : null; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** @param \DateTime|null|string $value */ |
||
| 32 | public function convertToPHPValue($value, AbstractPlatform $platform): ?\DateTime |
||
| 45 | } |
||
| 46 | } |
||
| 47 |