identifier = $identifier; $this->title = (string)$title; $this->link = (string)$link; $subTitle = trim($subTitle); if ($subTitle !== '') { $this->subTitle = $subTitle; } $additionalInfos = (array)$additionalInfos; foreach ($additionalInfos as $additionalInfo) { $additionalInfo = trim($additionalInfo); if ($additionalInfo !== '') { $this->additionalInfos[] = $additionalInfo; } } } /** * @param array $state * * @return self */ public static function fromDbState(array $state) { $additionalInfos = explode(' ## ' , $state['additional_infos']); return new self($state['index_id'], $state['title'], $state['link'], $state['subtitle'], $additionalInfos); } /** * @return int */ public function getIdentifier() { return $this->identifier; } /** * @return string */ public function getTitle() { return $this->title; } /** * @return string */ public function getLink() { return $this->link; } /** * @return string|null */ public function getSubTitle() { return $this->subTitle; } /** * @return array */ public function getAdditionalInfos() { return $this->additionalInfos; } /** * @return array */ public function jsonSerialize() { return [ 'type' => 'default', 'identifier' => $this->identifier, 'title' => $this->title, 'link' => $this->link, 'subtitle' => $this->subTitle, 'additionalInfos' => !empty($this->additionalInfos) ? $this->additionalInfos : null, ]; } }