2016-12-29 14:09:49 -06:00
|
|
|
<?php
|
2016-08-15 23:46:26 -05:00
|
|
|
|
2016-05-26 18:20:05 -05:00
|
|
|
namespace Amp\Internal;
|
|
|
|
|
2017-01-07 12:24:40 -06:00
|
|
|
use Amp\CallableMaker;
|
2017-01-03 19:10:27 -06:00
|
|
|
use Amp\Stream;
|
2016-05-26 18:20:05 -05:00
|
|
|
|
|
|
|
/**
|
2017-01-03 19:10:27 -06:00
|
|
|
* An stream that cannot externally emit values. Used by Emitter in development mode.
|
2016-06-01 11:37:12 -05:00
|
|
|
*
|
|
|
|
* @internal
|
2016-05-26 18:20:05 -05:00
|
|
|
*/
|
2017-01-03 19:10:27 -06:00
|
|
|
final class PrivateStream implements Stream {
|
2017-01-07 12:24:40 -06:00
|
|
|
use CallableMaker, Producer;
|
2016-05-26 18:20:05 -05:00
|
|
|
|
|
|
|
/**
|
2017-01-03 19:10:27 -06:00
|
|
|
* @param callable(callable $emit, callable $complete, callable $fail): void $producer
|
2016-05-26 18:20:05 -05:00
|
|
|
*/
|
2017-01-03 19:10:27 -06:00
|
|
|
public function __construct(callable $producer) {
|
2017-01-07 12:24:40 -06:00
|
|
|
$producer(
|
|
|
|
$this->callableFromInstanceMethod("emit"),
|
|
|
|
$this->callableFromInstanceMethod("resolve"),
|
|
|
|
$this->callableFromInstanceMethod("fail")
|
|
|
|
);
|
2016-05-26 18:20:05 -05:00
|
|
|
}
|
|
|
|
}
|