createdAt = new \DateTimeImmutable('now'); } /** * Get id. * * @return int * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * @return SurveyTemplateL11n * * @since 1.0.0 */ public function getL11n() : SurveyTemplateL11n { return $this->l11n ?? new NullSurveyTemplateL11n(); } /** * Set l11n * * @param SurveyTemplateL11n $l11n Template l11n * @param string $lang Language * * @return void * * @since 1.0.0 */ public function setL11n(SurveyTemplateL11n $l11n, string $lang = ISO639x1Enum::_EN) : void { $this->l11n = $l11n; } /** * Get tags * * @return array * * @since 1.0.0 */ public function getTags() : array { return $this->tags; } /** * Get tag. * * @param int $id Element id * * @return Tag * * @since 1.0.0 */ public function getTag(int $id) : Tag { return $this->tags[$id] ?? new NullTag(); } /** * Add tag * * @param Tag $tag Tag * * @return void * * @since 1.0.0 */ public function addTag(Tag $tag) : void { $this->tags[] = $tag; } /** * 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 all media * * @return Media[] * * @since 1.0.0 */ public function getMedia() : array { return $this->media; } /** * Add media * * @param Media $media Media to add * * @return void * * @since 1.0.0 */ public function addMedia(Media $media) : void { $this->media[] = $media; } /** * Get elements * * @return array * * @since 1.0.0 */ public function getElements() : array { return $this->elements; } /** * Add element * * @param SurveyTemplateElement $element Survey element to add * * @return void * * @since 1.0.0 */ public function addElement(SurveyTemplateElement $element) : void { $this->elements[] = $element; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'status' => $this->status, 'hasPublicResult' => $this->hasPublicResult, 'createdAt' => $this->createdAt, 'start' => $this->start, 'end' => $this->end, 'virtualPath' => $this->virtualPath, 'tags' => $this->tags, 'elements' => $this->elements, 'media' => $this->media, ]; } /** * {@inheritdoc} */ public function jsonSerialize() { return $this->toArray(); } }