ensureUploader($userId); $this->caption = $caption; } /** * @throws NotTaskImageUploader */ public function ensureRemovableBy(int $userId, bool $mayRemoveOthers): void { if (! $mayRemoveOthers) { $this->ensureUploader($userId); } } public function id(): ?int { return $this->id; } public function taskId(): int { return $this->taskId; } public function uploaderId(): ?int { return $this->uploaderId; } public function file(): StoredTaskImage { return $this->file; } public function originalName(): string { return $this->originalName; } public function caption(): ?TaskImageCaption { return $this->caption; } public function uploadedAt(): DateTimeImmutable { return $this->uploadedAt; } /** * @throws NotTaskImageUploader */ private function ensureUploader(int $userId): void { if ($this->uploaderId !== $userId) { throw new NotTaskImageUploader((int) $this->id, $userId); } } }