-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Expand file tree
/
Copy pathDatePointType.php
More file actions
44 lines (36 loc) · 1.01 KB
/
DatePointType.php
File metadata and controls
44 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bridge\Doctrine\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DateTimeImmutableType;
use Symfony\Component\Clock\DatePoint;
final class DatePointType extends DateTimeImmutableType
{
public const NAME = 'date_point';
/**
* @param T $value
*
* @return (T is null ? null : DatePoint)
*
* @template T
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DatePoint
{
if (null === $value || $value instanceof DatePoint) {
return $value;
}
$value = parent::convertToPHPValue($value, $platform);
return DatePoint::createFromInterface($value);
}
public function getName(): string
{
return self::NAME;
}
}