isWritable()) { throw new \LogicException("The destination is not writable"); } if (null !== $bytes) { return yield $destination->write( yield $source->read($bytes) ); } $written = 0; do { $written += yield $destination->write( yield $source->read() ); } while ($source->isReadable() && $destination->isWritable()); return $written; }