/** * Callback function for preg_replace_callback use. * * @param array $matches PREG matches * * @return string */ protected function pregCallback($matches) { switch (UTF8::strtolower($matches[1])) { case 'b': case 'strong': return $this->toupper($matches[3]); case 'th': return $this->toupper($matches[3] . "\n"); case 'h': return $this->toupper("\n\n" . $matches[3] . "\n\n"); case 'i': case 'em': $subject = $matches[3]; if ($this->options['do_underscores'] === true) { $subject = '_' . $subject . '_'; } return $subject; 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); default: return ''; } }
/** * Parses host part of url. * * @param string $host Host part of url * * @return Host Object representation of host portion of url */ public function parseHost($host) { $host = UTF8::strtolower($host); return new Host($this->getSubdomain($host), $this->getRegistrableDomain($host), $this->getPublicSuffix($host), $host); }
/** * Converts the first character of the string to lower case. * * @return Stringy Object with the first character of $str being lower case */ public function lowerCaseFirst() { $first = UTF8::substr($this->str, 0, 1, $this->encoding); $rest = UTF8::substr($this->str, 1, $this->length() - 1, $this->encoding); $str = UTF8::strtolower($first, $this->encoding) . $rest; return static::create($str, $this->encoding); }
/** * Check if an (case-insensitive) string is in the current array. * * @param string $value * * @return bool */ public function containsCaseInsensitive($value) { return in_array(UTF8::strtolower($value), array_map(array(new UTF8(), 'strtolower'), $this->array), true); }