Beispiel #1
0
 /**
  * Highlight words in text by current query request.
  * @param string $text
  * @param string $tag
  * @param array $properties
  * @return string
  */
 public function highlightText($text, $tag, array $properties = [])
 {
     $queries = explode(' ', $this->query);
     $dom = new Dom();
     foreach ($queries as $query) {
         $highlight = $dom->{$tag}(function () use($query) {
             return $query;
         }, $properties);
         $text = Str::ireplace($query, $highlight, $text);
     }
     return $text;
 }
Beispiel #2
0
 /**
  * Escape quotes
  * @param string $html
  * @return string
  */
 public function escapeQuotes($html)
 {
     return Str::ireplace(["\"", "'", """], '', $html);
 }