@@ 371-387 (lines=17) @@ | ||
368 | * @return string |
|
369 | * @link http://www.php.net/manual/en/function.fread.php |
|
370 | */ |
|
371 | public function read($length) |
|
372 | { |
|
373 | if (!$this->isReadable()) { |
|
374 | throw new Exception\BadMethodCallException('Stream not readable'); |
|
375 | } |
|
376 | ||
377 | if (!is_resource($this->resource)) { |
|
378 | throw new Exception\IOException('Invalid stream resource'); |
|
379 | } |
|
380 | ||
381 | $data = @fread($this->resource, $length); |
|
382 | if (false === $data) { |
|
383 | throw new Exception\IOException('Unexpected result of operation'); |
|
384 | } |
|
385 | ||
386 | return $data; |
|
387 | } |
|
388 | ||
389 | /** |
|
390 | * Read signed 8-bit integer (char) data from the stream. |
|
@@ 624-640 (lines=17) @@ | ||
621 | * @return int |
|
622 | * @link http://www.php.net/manual/en/function.fwrite.php |
|
623 | */ |
|
624 | public function write($data) |
|
625 | { |
|
626 | if (!$this->isWritable()) { |
|
627 | throw new Exception\BadMethodCallException('Stream not writable'); |
|
628 | } |
|
629 | ||
630 | if (!is_resource($this->resource)) { |
|
631 | throw new Exception\IOException('Invalid stream resource'); |
|
632 | } |
|
633 | ||
634 | $length = @fwrite($this->resource, $data); |
|
635 | if (false === $length) { |
|
636 | throw new Exception\IOException('Unexpected result of operation'); |
|
637 | } |
|
638 | ||
639 | return $length; |
|
640 | } |
|
641 | ||
642 | /** |
|
643 | * Write signed 8-bit integer (char) data to the stream |