private function processText($text) { // verify if content is a string otherwhise just return the original provided content if (!is_string($text) || empty($text)) { return $text; } // find all tags based on the REGEX expression preg_match_all(static::REGEX, $text, $results, PREG_SET_ORDER); // foreach all the results matches the regex foreach ($results as $row) { // When value is empty (can be caused by using `link[]` we have to skip this item. if (empty($row['value'])) { continue; } $tag = $row['function']; if ($this->hasTag($tag)) { $replace = $this->evalTag($tag, $row); $text = preg_replace('[' . preg_quote($row[0]) . ']mi', $replace, $text, 1); } } return $text; }