Пример #1
0
 /**
  * @inheritdoc
  * @param StreamInterface $destination
  * @param int|null $bufferSize
  */
 public function copyTo(StreamInterface $destination, $bufferSize = null)
 {
     if (null === $destination) {
         throw new Exception\InvalidArgumentException('destination');
     }
     if (!$this->canRead() && !$this->canWrite()) {
         throw new Exception\ObjectDisposedException('this');
     }
     if (!$destination->canRead() && !$destination->canWrite()) {
         throw new Exception\ObjectDisposedException('destination');
     }
     if (!$this->canRead()) {
         throw new Exception\NotSupportedException();
     }
     if (!$destination->canWrite()) {
         throw new Exception\NotSupportedException();
     }
     $this->internalCopyTo($destination, $bufferSize);
 }
Пример #2
0
 /**
  * @return bool
  */
 public function canRead()
 {
     return $this->stream->canRead();
 }
Пример #3
0
 public function copyTo(StreamInterface $destination, $bufferSize = null)
 {
     if (null === $destination) {
         throw new Exception\InvalidArgumentException('destination');
     }
     if (!$this->canRead() && !$this->canWrite()) {
         throw new Exception\ObjectDisposedException('this');
     }
     if (!$destination->canRead() && !$destination->canWrite()) {
         throw new Exception\ObjectDisposedException('destination');
     }
     if (!$this->canRead()) {
         throw new Exception\NotSupportedException();
     }
     if (!$destination->canWrite()) {
         throw new Exception\NotSupportedException();
     }
     if (null !== $bufferSize && $bufferSize <= 0) {
         throw new Exception\InvalidArgumentException('bufferSize', $bufferSize, 'Parameter "bufferSize" must be greater than 0.');
     }
     // Copy in chunks
     $bufferSize = $bufferSize ?: $this->defaultCopyBufferSize;
     while (($data = $this->read($bufferSize)) !== null) {
         $destination->write($data);
     }
 }
Пример #4
0
 /**
  * @return bool
  */
 public function canRead()
 {
     $this->initializeStream();
     return $this->stream->canRead();
 }