text = $text; $this->createdAt = $createdAt; $this->rec = $rec; $this->post = $post; $this->number = $number; $this->toNumber = $toNumber; $this->author = $author; $this->files = new ArrayCollection(); foreach ($files as $file) { if (!($file instanceof File)) { throw new \RuntimeException(sprintf( '$files array must contain only \'%s\' objects. %s given.', \is_object($file) ? \get_class($file) : \gettype($file) )); } $this->files->add($file); } } public function getId(): int { return $this->id; } public function getCreatedAt(): \DateTime { return $this->createdAt; } public function getText(): string { return $this->text; } public function isRec(): bool { return $this->rec; } public function getPost(): Post { return $this->post; } public function getNumber(): int { return $this->number; } public function getToNumber(): ?int { return $this->toNumber; } public function getAuthor(): User { return $this->author; } /** * @return File[]|ArrayCollection */ public function getFiles(): iterable { return $this->files; } public function delete(): self { $this->deleted = true; return $this; } public function restore(): self { $this->deleted = false; return $this; } public function isDeleted(): bool { return $this->deleted; } }