createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable('now'); $this->location = new Location(); $this->schedule = new Schedule(); } /** * @return int * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * @return Account[] * * @since 1.0.0 */ public function getPeople() : array { return $this->people; } /** * @param int $id Account id * * @return Account * * @since 1.0.0 */ public function getPerson(int $id) : Account { return $this->people[$id] ?? new NullAccount(); } /** * @param Account $person Person to add * * @return void * * @since 1.0.0 */ public function addPerson(Account $person) : void { $this->people[$person->getId()] = $person; } /** * Remove Element from list. * * @param int $id Task element * * @return bool * * @since 1.0.0 */ public function removePerson(int $id) : bool { if (isset($this->people[$id])) { unset($this->people[$id]); return true; } return false; } /** * @return Account * * @since 1.0.0 */ public function getCreatedBy() : Account { return $this->createdBy; } /** * Set creator * * @param Account $createdBy Creator * * @return void * * @since 1.0.0 */ public function setCreatedBy(Account $createdBy) : void { $this->createdBy = $createdBy; if ($this->schedule instanceof Schedule) { $this->schedule->createdBy = $this->createdBy; } } /** * Set location * * @param Location $location Event location * * @return void * * @since 1.0.0 */ public function setLocation(Location $location) : void { $this->location = $location; } /** * @return Location * * @since 1.0.0 */ public function getLocation() : Location { return $this->location; } /** * @return int * * @since 1.0.0 */ public function getCalendar() : int { return $this->calendar; } /** * @return int * * @since 1.0.0 */ public function getType() : int { return $this->type; } /** * @return int * * @since 1.0.0 */ public function getStatus() : int { return $this->status; } /** * @param int $calendar Calendar * * @since 1.0.0 */ public function setCalendar(int $calendar) : void { $this->calendar = $calendar; } /** * @return Schedule * * @since 1.0.0 */ public function getSchedule() : Schedule { return $this->schedule; } /** * Adding new tag. * * @param Tag $tag Tag * * @return int * * @since 1.0.0 */ public function addTag(Tag $tag) : int { $this->tags[] = $tag; \end($this->tags); $key = (int) \key($this->tags); \reset($this->tags); return $key; } /** * Remove Tag from list. * * @param int $id Tag * * @return bool * * @since 1.0.0 */ public function removeTag($id) : bool { if (isset($this->tags[$id])) { unset($this->tags[$id]); return true; } return false; } /** * Get task elements. * * @return Tag[] * * @since 1.0.0 */ public function getTags() : array { return $this->tags; } /** * Get task elements. * * @param int $id Element id * * @return Tag * * @since 1.0.0 */ public function getTag(int $id) : Tag { return $this->tags[$id] ?? new NullTag(); } }