Beispiel #1
0
 /**
  * "strtoupper" function with HTML tags and entities handling.
  *
  * @param  string $str Text to convert
  *
  * @return string Converted text
  */
 private function toupper($str)
 {
     if ($this->options['do_upper'] !== true) {
         return $str;
     }
     // string can contain HTML tags
     $chunks = preg_split('/(<[^>]*>)/', $str, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
     // convert toupper only the text between HTML tags
     foreach ($chunks as $i => &$chunk) {
         if ($chunk[0] != '<') {
             $chunk = UTF8::strtoupper($chunk);
         }
     }
     return implode($chunks);
 }
Beispiel #2
0
 /**
  * @param string $word
  *
  * @return string
  */
 private function capitalizeWord($word)
 {
     $encoding = $this->encoding;
     $firstCharacter = UTF8::substr($word, 0, 1, $encoding);
     $restOfWord = UTF8::substr($word, 1, null, $encoding);
     $firstCharacterUppercased = UTF8::strtoupper($firstCharacter, $encoding);
     return new static($firstCharacterUppercased . $restOfWord, $encoding);
 }