| @@ 99-113 (lines=15) @@ | ||
| 96 | * @return int Position of the file pointer |
|
| 97 | * @throws RuntimeException on error. |
|
| 98 | */ |
|
| 99 | public function tell() |
|
| 100 | { |
|
| 101 | if (!$this->stream) { |
|
| 102 | throw new RuntimeException( |
|
| 103 | 'No resource available; cannot tell position' |
|
| 104 | ); |
|
| 105 | } |
|
| 106 | $result = ftell($this->stream); |
|
| 107 | if (!is_int($result)) { |
|
| 108 | throw new RuntimeException( |
|
| 109 | 'Error occurred during tell operation' |
|
| 110 | ); |
|
| 111 | } |
|
| 112 | return $result; |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Returns true if the stream is at the end of the stream. |
|
| @@ 278-288 (lines=11) @@ | ||
| 275 | * @throws RuntimeException if unable to read or an error occurs while |
|
| 276 | * reading. |
|
| 277 | */ |
|
| 278 | public function getContents() |
|
| 279 | { |
|
| 280 | if (! $this->isReadable()) { |
|
| 281 | throw new RuntimeException('Stream is not readable'); |
|
| 282 | } |
|
| 283 | $result = stream_get_contents($this->stream); |
|
| 284 | if (false === $result) { |
|
| 285 | throw new RuntimeException('Error reading from stream'); |
|
| 286 | } |
|
| 287 | return $result; |
|
| 288 | } |
|
| 289 | ||
| 290 | /** |
|
| 291 | * Get stream metadata as an associative array or retrieve a specific key. |
|