function CodePointString::replace
Overrides AbstractString::replace
File
-
vendor/
symfony/ string/ CodePointString.php, line 168
Class
- CodePointString
- Represents a string of Unicode code points encoded as UTF-8.
Namespace
Symfony\Component\StringCode
public function replace(string $from, string $to) : static {
$str = clone $this;
if ('' === $from || !preg_match('//u', $from)) {
return $str;
}
if ('' !== $to && !preg_match('//u', $to)) {
throw new InvalidArgumentException('Invalid UTF-8 string.');
}
if ($this->ignoreCase) {
$str->string = implode($to, preg_split('{' . preg_quote($from) . '}iuD', $this->string));
}
else {
$str->string = str_replace($from, $to, $this->string);
}
return $str;
}