$params */ public function __construct( public int $userId, public NotificationType $type, public array $params, public string $dedupeKey, public DateTimeImmutable $createdAt, ) {} /** * @param array $params */ public static function taskStartsSoon(int $userId, int $taskId, string $startsOn, array $params, DateTimeImmutable $at): self { return new self($userId, NotificationType::TaskStartsSoon, $params, "task_starts:{$taskId}:{$startsOn}:{$userId}", $at); } /** * One notification per maintenance need: the item, its last maintenance * and the level (coming up or late). * * @param array $params */ public static function maintenanceDue(int $userId, int $itemId, ?int $lastRecordId, string $level, array $params, DateTimeImmutable $at): self { return new self($userId, NotificationType::MaintenanceDue, $params, 'maintenance:'.$itemId.':'.($lastRecordId ?? 'start').':'.$level.':'.$userId, $at); } /** * Each assignment is its own notification: one removed and added again * is told again. * * @param array $params */ public static function assigned(NotificationType $type, int $userId, int $subjectId, array $params, DateTimeImmutable $at): self { return new self($userId, $type, $params, "{$type->value}:{$subjectId}:{$userId}:".$at->format('U.u').':'.bin2hex(random_bytes(4)), $at); } }