You are here

protected function Html2Text::pregCallback in Swift Mailer 7

Callback function for preg_replace_callback use.

Parameters

array $matches PREG matches:

Return value

string

File

includes/classes/Html2Text.inc, line 517

Class

Html2Text

Code

protected function pregCallback($matches) {
  switch (strtolower($matches[1])) {
    case 'b':
    case 'strong':
      return $this
        ->toupper($matches[3]);
    case 'th':
      return $this
        ->toupper("\t\t" . $matches[3] . "\n");
    case 'h':
      return $this
        ->toupper("\n\n" . $matches[3] . "\n\n");
    case 'a':

      // override the link method
      $linkOverride = null;
      if (preg_match('/_html2text_link_(\\w+)/', $matches[4], $linkOverrideMatch)) {
        $linkOverride = $linkOverrideMatch[1];
      }

      // Remove spaces in URL (#1487805)
      $url = str_replace(' ', '', $matches[3]);
      return $this
        ->buildlinkList($url, $matches[5], $linkOverride);
  }
  return '';
}