/** * Extract relevant summary from text * * @param string|null $text * @param int|null $limit * @param bool|true $withoutStopWords * * @return string */ public function summary($text = null, $limit = null, $withoutStopWords = true) { $config = new Config(); if ($withoutStopWords) { $config->addListener(new Stopword()); } $analyzer = new Summary($config); try { $summary = $analyzer->getSummary($this->cleanup($text)); if ($summary && is_integer($limit)) { $summary = mb_strimwidth($summary, 0, $limit, "..."); } } catch (\RuntimeException $e) { $summary = null; } return $summary; }