You are here

public static function Typogrify::capWrapper in Typogrify 8

Helper method for caps method - used for preg_replace_callback.

File

src/Typogrify.php, line 51

Class

Typogrify
Class \Drupal\typogrify\Typogrify.

Namespace

Drupal\typogrify

Code

public static function capWrapper($matchobj) {
  if (!empty($matchobj[2])) {
    return sprintf('<span class="caps">%s</span>', $matchobj[2]);
  }
  else {
    $mthree = $matchobj[3];
    if ($mthree[strlen($mthree) - 1] == ' ') {
      $caps = substr($mthree, 0, -1);
      $tail = ' ';
    }
    else {
      $caps = $mthree;
      $tail = $matchobj[4];
    }
    return sprintf('<span class="caps">%s</span>%s', $caps, $tail);
  }
}