| @@ 353-369 (lines=17) @@ | ||
| 350 | * @return string |
|
| 351 | * @link http://www.php.net/manual/en/function.fread.php |
|
| 352 | */ |
|
| 353 | public function read($length) |
|
| 354 | { |
|
| 355 | if (!$this->isReadable()) { |
|
| 356 | throw new Exception\BadMethodCallException('Stream not readable'); |
|
| 357 | } |
|
| 358 | ||
| 359 | if (!is_resource($this->resource)) { |
|
| 360 | throw new Exception\IOException('Invalid stream resource'); |
|
| 361 | } |
|
| 362 | ||
| 363 | $data = @fread($this->resource, $length); |
|
| 364 | if (false === $data) { |
|
| 365 | throw new Exception\IOException('Unexpected result of operation'); |
|
| 366 | } |
|
| 367 | ||
| 368 | return $data; |
|
| 369 | } |
|
| 370 | ||
| 371 | /** |
|
| 372 | * Read signed 8-bit integer (char) data from the stream. |
|
| @@ 606-622 (lines=17) @@ | ||
| 603 | * @return int |
|
| 604 | * @link http://www.php.net/manual/en/function.fwrite.php |
|
| 605 | */ |
|
| 606 | public function write($data) |
|
| 607 | { |
|
| 608 | if (!$this->isWritable()) { |
|
| 609 | throw new Exception\BadMethodCallException('Stream not writable'); |
|
| 610 | } |
|
| 611 | ||
| 612 | if (!is_resource($this->resource)) { |
|
| 613 | throw new Exception\IOException('Invalid stream resource'); |
|
| 614 | } |
|
| 615 | ||
| 616 | $length = @fwrite($this->resource, $data); |
|
| 617 | if (false === $length) { |
|
| 618 | throw new Exception\IOException('Unexpected result of operation'); |
|
| 619 | } |
|
| 620 | ||
| 621 | return $length; |
|
| 622 | } |
|
| 623 | ||
| 624 | /** |
|
| 625 | * Write signed 8-bit integer (char) data to the stream |
|