Ejemplo n.º 1
0
 public function stream_write($data)
 {
     return (int) $this->stream->write($data);
 }
Ejemplo n.º 2
0
 /**
  * Copy the contents of a stream into another stream until the given number
  * of bytes have been read.
  *
  * @param puzzle_stream_StreamInterface $source Stream to read from
  * @param puzzle_stream_StreamInterface $dest   Stream to write to
  * @param int                           $maxLen Maximum number of bytes to read. Pass -1
  *                                              to read the entire stream.
  */
 public static function copyToStream(puzzle_stream_StreamInterface $source, puzzle_stream_StreamInterface $dest, $maxLen = -1)
 {
     if ($maxLen === -1) {
         while (!$source->eof()) {
             if (!$dest->write($source->read(1048576))) {
                 break;
             }
         }
         return;
     }
     $bytes = 0;
     while (!$source->eof()) {
         $buf = $source->read($maxLen - $bytes);
         if (!($len = strlen($buf))) {
             break;
         }
         $bytes += $len;
         $dest->write($buf);
         if ($bytes == $maxLen) {
             break;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function write($string)
 {
     return $this->_delegate->write($string);
 }