| @@ 112-120 (lines=9) @@ | ||
| 109 | * @param string $data |
|
| 110 | * @throws OutOfBoundsException |
|
| 111 | */ |
|
| 112 | public function insert($data) |
|
| 113 | { |
|
| 114 | if (!$this->valid()) |
|
| 115 | { |
|
| 116 | throw new OutOfBoundsException('The iterator is not valid!'); |
|
| 117 | } |
|
| 118 | ||
| 119 | $this->buffer[$this->current] = $data . $this->buffer[$this->current]; |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * Replace the byte at the current iterator position with the given string. |
|
| @@ 129-141 (lines=13) @@ | ||
| 126 | * @return string |
|
| 127 | * @throws OutOfBoundsException |
|
| 128 | */ |
|
| 129 | public function replace($data) |
|
| 130 | { |
|
| 131 | if (!$this->valid()) |
|
| 132 | { |
|
| 133 | throw new OutOfBoundsException('The iterator is not valid!'); |
|
| 134 | } |
|
| 135 | ||
| 136 | $temp = $this->buffer[$this->current]; |
|
| 137 | ||
| 138 | $this->buffer[$this->current] = $data; |
|
| 139 | ||
| 140 | return $temp; |
|
| 141 | } |
|
| 142 | ||
| 143 | /** |
|
| 144 | * Remove the byte at the current iterator position and moves the iterator to the previous character. |
|
| @@ 149-163 (lines=15) @@ | ||
| 146 | * @return string |
|
| 147 | * @throws OutOfBoundsException |
|
| 148 | */ |
|
| 149 | public function remove() |
|
| 150 | { |
|
| 151 | if (!$this->valid()) |
|
| 152 | { |
|
| 153 | throw new OutOfBoundsException('The iterator is not valid!'); |
|
| 154 | } |
|
| 155 | ||
| 156 | $temp = $this->buffer[$this->current]; |
|
| 157 | ||
| 158 | unset($this->buffer[$this->current]); |
|
| 159 | ||
| 160 | --$this->current; |
|
| 161 | ||
| 162 | return $temp; |
|
| 163 | } |
|
| 164 | } |
|
| 165 | ||