Total Complexity | 3 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class NonBlockingResourceInputStream implements InputStream |
||
8 | { |
||
9 | /** |
||
10 | * @var InputStream |
||
11 | */ |
||
12 | private $innerStream; |
||
13 | |||
14 | /** |
||
15 | * @param resource $stream |
||
16 | */ |
||
17 | public function __construct($stream = null) |
||
18 | { |
||
19 | $this->innerStream = new ResourceInputStream($stream ?? STDIN); |
||
20 | stream_set_blocking($stream, false); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @inheritDoc |
||
25 | */ |
||
26 | public function read(int $numBytes, callable $callback): void |
||
27 | { |
||
28 | $this->innerStream->read($numBytes, $callback); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @inheritDoc |
||
33 | */ |
||
34 | public function isInteractive(): bool |
||
37 | } |
||
38 | } |
||
39 |