src/Text.php
public function replace(Text $search, Text $replace): Text {
    return new static(str_replace((string)$search, (string)$replace, $this->raw));
  }
public function replace(Text $search, Text $replace): Text {
    return new static(str_replace((string)$search, (string)$replace, $this->raw));
  }
Replaces parts of this Text object based on a search and replace

@param  Text  $search   The text to find
@param  Text  $replace  The text with which to replace the found text

@return  Text  A new Text object containing this Text object, with all search text replaced