2016-12-30 06:09:06 +01:00
|
|
|
<?php
|
2016-08-16 23:23:46 +02:00
|
|
|
|
2017-03-16 16:22:32 +01:00
|
|
|
namespace Amp\ByteStream;
|
2016-08-10 23:48:42 +02:00
|
|
|
|
2017-03-16 16:22:32 +01:00
|
|
|
use Amp\{ Coroutine, Promise };
|
2016-08-10 23:48:42 +02:00
|
|
|
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
if (\strlen('…') !== 3) {
|
2016-08-16 00:19:32 +02:00
|
|
|
throw new \Error(
|
2016-08-10 23:48:42 +02:00
|
|
|
'The mbstring.func_overload ini setting is enabled. It must be disable to use the stream package.'
|
|
|
|
);
|
|
|
|
} // @codeCoverageIgnoreEnd
|
|
|
|
|
|
|
|
/**
|
2017-03-16 16:22:32 +01:00
|
|
|
* @param \Amp\ByteStream\ByteStream $source
|
|
|
|
* @param \Amp\ByteStream\ByteStream $destination
|
2016-08-10 23:48:42 +02:00
|
|
|
* @param int|null $bytes
|
|
|
|
*
|
2017-03-16 16:22:32 +01:00
|
|
|
* @return \Amp\Promise
|
2016-08-10 23:48:42 +02:00
|
|
|
*/
|
2017-01-09 17:52:29 +01:00
|
|
|
function pipe(ByteStream $source, ByteStream $destination, int $bytes = null): Promise {
|
2017-01-09 17:53:36 +01:00
|
|
|
return new Coroutine(Internal\pipe($source, $destination, $bytes));
|
2016-08-10 23:48:42 +02:00
|
|
|
}
|