sendDate = new DateTime('now'); $this->updateDate = $this->sendDate; $this->content = ''; $this->attachments = new ArrayCollection(); $this->children = new ArrayCollection(); $this->likes = new ArrayCollection(); $this->votes = 0; } public function setUserSender(User $userSender): self { $this->userSender = $userSender; return $this; } public function getUserSender(): User { return $this->userSender; } public function setUserReceiver(User $userReceiver): self { $this->userReceiver = $userReceiver; return $this; } /** * Get userReceiver. * * @return User */ public function getUserReceiver() { return $this->userReceiver; } public function setMsgStatus(int $msgStatus): self { $this->msgStatus = $msgStatus; return $this; } public function getMsgStatus(): int { return $this->msgStatus; } /** * Set sendDate. * * @param DateTime $sendDate * * @return Message */ public function setSendDate($sendDate) { $this->sendDate = $sendDate; return $this; } /** * Get sendDate. * * @return DateTime */ public function getSendDate() { return $this->sendDate; } /** * Set title. * * @param string $title */ public function setTitle($title): self { $this->title = $title; return $this; } /** * Get title. * * @return string */ public function getTitle() { return $this->title; } /** * Set content. * * @param string $content */ public function setContent($content): self { $this->content = $content; return $this; } /** * Get content. * * @return string */ public function getContent() { return $this->content; } /** * Set groupId. * * @param int $groupId * * @return Message */ public function setGroupId($groupId) { $this->groupId = $groupId; return $this; } /** * Get groupId. * * @return int */ public function getGroupId() { return $this->groupId; } /** * Set updateDate. * * @param DateTime $updateDate * * @return Message */ public function setUpdateDate($updateDate) { $this->updateDate = $updateDate; return $this; } /** * Get updateDate. * * @return DateTime */ public function getUpdateDate() { return $this->updateDate; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Set votes. * * @param int $votes */ public function setVotes($votes): self { $this->votes = $votes; return $this; } /** * Get votes. * * @return int */ public function getVotes() { return $this->votes; } /** * Get attachments. * * @return Collection|MessageAttachment[] */ public function getAttachments() { return $this->attachments; } public function addAttachment(MessageAttachment $attachment): self { $this->attachments->add($attachment); $attachment->setMessage($this); return $this; } public function getParent(): ?self { return $this->parent; } /** * @return Collection|Message[] */ public function getChildren() { return $this->children; } public function addChild(self $child): self { $this->children[] = $child; $child->setParent($this); return $this; } public function setParent(self $parent = null): self { $this->parent = $parent; return $this; } /** * @return MessageFeedback[]|Collection */ public function getLikes() { return $this->likes; } /** * Get an excerpt from the content. * * @param int $length Optional. Length of the excerpt. */ public function getExcerpt(int $length = 50): string { $striped = strip_tags($this->content); $replaced = str_replace(["\r\n", "\n"], ' ', $striped); $trimmed = trim($replaced); return api_trunc_str($trimmed, $length); } }