public function testSubstring() { $this->eq(s::substring('abcdef', 2, 3), 'cde'); $this->eq(s::substring('abcdef', 2), 'cdef'); $this->eq(s::substring('abcdef', 2, 1000), 'cdef'); $this->eq(s::substring('abcdef', 1000), ''); $this->eq(s::substring('abcdef', 1000, 3), ''); $this->eq(s::substring('abcdef', 2, 0), ''); $this->eq(s::substring('abcdef', -2), 'ef'); $this->eq(s::substring('abcdef', -4, 2), 'cd'); $this->eq(s::substring('abcdef', -1000), 'abcdef'); $this->eq(s::substring('abcdef', -7, 3), 'ab'); $this->eq(s::substring('', 2, 4), ''); }
public function substring($offset, $length = null) { return new self(s::substring($this->value, $offset, $length)); }