12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- class StringReader extends Reader {
-
-
- private $_string;
-
-
- private $mark = 0;
-
-
- private $currPos = 0;
-
- function __construct($string) {
- $this->_string = $string;
- }
- function skip($n) {}
- function read($len = null) {
- if ($len === null) {
- return $this->_string;
- } else {
- if ($this->currPos >= strlen($this->_string)) {
- return -1;
- }
- $out = substr($this->_string, $this->currPos, $len);
- $this->currPos += $len;
- return $out;
- }
- }
- function mark() {
- $this->mark = $this->currPos;
- }
- function reset() {
- $this->currPos = $this->mark;
- }
- function close() {}
- function open() {}
- function ready() {}
- function markSupported() {
- return true;
- }
-
- function getResource() {
- return '(string) "'.$this->_string . '"';
- }
- }
|