account = new NullAccount(); } /** * Adding board component. * * @param DashboardComponent $element Task element * * @return int * * @since 1.0.0 */ public function addComponent(DashboardComponent $element) : int { $this->components[] = $element; \end($this->components); $key = (int) \key($this->components); \reset($this->components); return $key; } /** * Remove component from list. * * @param int $id Board component * * @return bool * * @since 1.0.0 */ public function removeComponent($id) : bool { if (isset($this->components[$id])) { unset($this->components[$id]); return true; } return false; } /** * Get board components. * * @return DashboardComponent[] * * @since 1.0.0 */ public function getComponents() : array { return $this->components; } /** * Get board component. * * @param int $id Component id * * @return DashboardComponent * * @since 1.0.0 */ public function getComponent(int $id) : DashboardComponent { return $this->components[$id] ?? new NullDashboardComponent(); } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'account' => $this->account, 'title' => $this->title, 'status' => $this->status, 'components' => $this->components, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } }