for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Bone\BoneDoctrine\Traits;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use Doctrine\ORM\Mapping as ORM;
#[ORM\HasLifecycleCallbacks]
trait HasCreatedAtDate
{
#[ORM\Column(type: 'datetime_immutable')]
private DateTimeInterface $createdAt;
public function getCreatedAt(): DateTimeInterface
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
$this->createdAt = new DateTimeImmutable('now', new DateTimeZone('UTC'));