'CURRENT_TIMESTAMP'])] private \DateTime $date_time; #[ORM\Column(type: 'boolean')] private bool $is_sensitive; // "sensitive" tout court est un mot réservé #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] private \DateTime $last_contact_date; #[ORM\Column(type: 'datetime', nullable: true)] private ?\DateTime $is_sensitive_since; public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, bool $sensitive = false){ $this->sender_name = strtolower($sender_name); $this->sender_address = strtolower($sender_address); $this->recipient = strtolower($recipient); $this->content = $content; $this->date_time = new \DateTime; $this->last_contact_date = new \DateTime; $this->makeSensitive($sensitive); } public function getId(): int { return $this->id_email; } public function getSenderName(): string { return $this->sender_name; } public function getSenderAddress(): string { return $this->sender_address; } public function getRecipient(): string { return $this->recipient; } public function getContent(): string { return $this->content; } public function getDateTime(): \DateTime { return $this->date_time; } /*public function getLastContactDate(): \DateTime { return $this->last_contact_date; }*/ public function isSensitive(): bool { return $this->is_sensitive; } public function isSensitiveSince(): ?\DateTime { return $this->is_sensitive_since; } public function makeSensitive(bool $sensitive = true): void { $this->is_sensitive = $sensitive; if($sensitive && $this->is_sensitive_since === null){ $this->is_sensitive_since = new \DateTime(); } } public function updateLastContactDate(): void { $this->last_contact_date = new \DateTime; } public function getDeletionDate(): \DateTime { return $this->is_sensitive // oui durée 5 ans, non durée 3 ans "glissante" ? (clone $this->is_sensitive_since)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD_SENSITIVE . ' month') // erreur si vrai mais sans date (pas censé arriver) : (clone $this->last_contact_date)->modify('+ ' . (string)self::LEGAL_RETENTION_PERIOD . ' month'); } }