createdAt = new \DateTimeImmutable('now'); $this->createdBy = new NullAccount(); } /** * Count the amount of comments in a card * * @return int * * @since 1.0.0 */ public function getCommentCount() : int { return \count($this->comments); } /** * Get the comments * * @return array * * @since 1.0.0 */ public function getComments() : array { return $this->comments; } /** * Add a comment * * @param KanbanCardComment $comment Comment * * @return void * * @since 1.0.0 */ public function addComment(KanbanCardComment $comment) : void { $this->comments[] = $comment; } /** * Remove a comment * * @param int $id Comment id * * @return bool * * @since 1.0.0 */ public function removeComment(int $id) : bool { if (isset($this->comments[$id])) { unset($this->comments[$id]); return true; } return false; } /** * Add tag * * @param Tag $tag Tag * * @return void * * @since 1.0.0 */ public function addTag(Tag $tag) : void { $this->tags[] = $tag; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'title' => $this->name, 'description' => $this->description, 'descriptionRaw' => $this->descriptionRaw, 'status' => $this->status, 'type' => $this->type, 'column' => $this->column, 'order' => $this->order, 'ref' => $this->ref, 'createdBy' => $this->createdBy, 'createdAt' => $this->createdAt, 'comments' => $this->comments, 'media' => $this->files, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } /** * Create a task from a card * * @param Task $task Task to create the card from * * @return KanbanCard * * @since 1.0.0 */ public static function createFromTask(Task $task) : self { $card = new self(); $card->ref = $task->id; return $card; } use \Modules\Media\Models\MediaListTrait; }