public function testReplaceAndCount() { $this->eq(s::replaceAndCount('abcxabc', 'x', 'y'), array('abcyabc', 1)); $this->eq(s::replaceAndCount('afoobara', 'foobar', 'b'), array('aba', 1)); $this->eq(s::replaceAndCount('aaxyaaaxya', 'xy', 'b'), array('aabaaaba', 2)); $this->eq(s::replaceAndCount('', 'abc', ''), array('', 0)); $this->eq(s::replaceAndCount('abc', '', 'x'), array('xaxbxcx', 4)); $this->eq(s::replaceAndCount('', '', 'x'), array('x', 1)); }
public function replaceAndCount($old, $new) { $r = s::replaceAndCount($this->value, self::unwrap($old), self::unwrap($new)); $r[0] = new self($r[0]); return $r; }