2023-08-08 23:53:49 -04:00
|
|
|
<?php
|
|
|
|
namespace Incoviba\Common\Implement\Repository\Mapper;
|
|
|
|
|
|
|
|
use DateTimeImmutable;
|
|
|
|
use Incoviba\Common\Implement\Repository\Mapper;
|
|
|
|
|
|
|
|
class DateTime extends Mapper
|
|
|
|
{
|
|
|
|
public function __construct(string $column, ?string $property = null)
|
|
|
|
{
|
|
|
|
$this->setFunction(function($data) use ($column) {
|
2023-12-22 14:14:02 -03:00
|
|
|
return new DateTimeImmutable($data[$column] ?? '');
|
2023-08-08 23:53:49 -04:00
|
|
|
});
|
|
|
|
if ($property !== null) {
|
|
|
|
$this->setProperty($property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|