projectId = (int)$projectId; $this->title = (string)$title; $this->link = (string)$link; $this->addSearchWords($words); } /** * @param array $state * * @return self */ public static function fromDbState(array $state) { return new self( (string)$state['title'], (string)$state['link'], (int)$state['project_id'], (array)$state['search_words'] ); } /** * @param string $subTitle * * @return void */ public function setSubTitle($subTitle) { $subTitle = trim($subTitle); if ($subTitle === '') { return; } $this->subTitle = (string)$subTitle; } /** * @param string $additionalInfo * * @return void */ public function addAdditionalInfo($additionalInfo) { $additionalInfo = trim($additionalInfo); if ($additionalInfo === '') { return; } $this->additionalInfos[] = (string)$additionalInfo; } /** * @param array|string[] $words * * @return void */ public function addSearchWords(array $words) { foreach ($words as $word) { $this->addSearchWord($word); } } /** * @param string $word * * @return void */ public function addSearchWord($word) { $word = trim($word); if ($word === '') { return; } $this->words[] = $word; } /** * @return string */ public function getTitle() { return $this->title; } /** * @return string|null */ public function getSubTitle() { return $this->subTitle; } /** * @return array|string[] */ public function getAdditionalInfos() { return $this->additionalInfos; } /** * @return string */ public function getLink() { return $this->link; } /** * @return int */ public function getProjectId() { return $this->projectId; } /** * @return array */ public function getWords() { return $this->words; } }