Passed
Pull Request — master (#12)
by Aydin
01:54
created

NonBlockingResourceInputStream::isInteractive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSchool\Terminal\IO;
6
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
35
    {
36
        return $this->innerStream->isInteractive();
37
    }
38
}
39