*/ final class Shopper implements Entity { private const string BUSINESS_TIMEZONE = 'Europe/Paris'; public function __construct( private readonly ShopperId $id, public readonly Email $email, public readonly Matricule $matricule, public readonly string $nom, public readonly string $prenom, public readonly CarbonInterface $startDate, public readonly ?CarbonInterface $endDate, public readonly ShopperEstablishmentCode $etablissement, public readonly ShopperSiteCode $site, public readonly ShopperServiceCode $service ) { if (trim($nom) === '') { throw new \DomainException('nom cannot be empty'); } if (trim($prenom) === '') { throw new \DomainException('prenom cannot be empty'); } } #[\Override] public function id(): ShopperId { return $this->id; } public function isActive(): bool { $todayParis = CarbonImmutable::now(self::BUSINESS_TIMEZONE)->format('Y-m-d'); if ($this->startDate->format('Y-m-d') > $todayParis) { return false; } return $this->endDate === null || $this->endDate->format('Y-m-d') > $todayParis; } }