-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mapping to object with non null datetime (#91)
* add support of dateTimeImmutable on the owning side * fix: mapping to object with non null datetime * remove null requirement on the target side * fix datepoint --------- Co-authored-by: Vladyslav Yarysh <vladyslav.yarysh@macpaw.com>
- Loading branch information
Showing
4 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Fixtures\DateTime; | ||
|
||
use Symfony\Component\Clock\DatePoint; | ||
|
||
class ObjectWithDateTime | ||
{ | ||
public const DATETIME = '2024-01-01 00:00:00'; | ||
|
||
public function getDateTimeImmutable(): \DateTimeImmutable | ||
{ | ||
return new \DateTimeImmutable(self::DATETIME); | ||
} | ||
public function getDateTime(): \DateTime | ||
{ | ||
return new \DateTime(self::DATETIME); | ||
} | ||
|
||
public function getDatePoint(): DatePoint | ||
{ | ||
return new DatePoint(self::DATETIME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Fixtures\DateTime; | ||
|
||
use Symfony\Component\Clock\DatePoint; | ||
|
||
class ObjectWithDateTimeDto | ||
{ | ||
public const DATETIME = '2023-01-01 00:00:00'; | ||
|
||
public static function getInitialized(): self | ||
{ | ||
$dto = new self(); | ||
$dto->dateTimeImmutable = new \DateTimeImmutable(self::DATETIME); | ||
$dto->dateTime = new \DateTime(self::DATETIME); | ||
$dto->datePoint = new DatePoint(self::DATETIME); | ||
|
||
return $dto; | ||
} | ||
|
||
public ?\DateTimeImmutable $dateTimeImmutable = null; | ||
public ?\DateTime $dateTime = null; | ||
public ?DatePoint $datePoint = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters