-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleOutputStream.php
More file actions
55 lines (49 loc) · 1009 Bytes
/
ConsoleOutputStream.php
File metadata and controls
55 lines (49 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace WebStream\IO;
/**
* ConsoleOutputStream
* @author Ryuichi TANAKA.
* @since 2016/02/27
* @version 0.7
*/
class ConsoleOutputStream extends OutputStream
{
/**
* constructor
*/
public function __construct()
{
parent::__construct("");
}
/**
* {@inheritdoc}
*/
public function write($buf, int $off = null, int $len = null)
{
$data = null;
if ($off === null && $len === null) {
$data = $buf;
} elseif ($off !== null && $len === null) {
$data = substr($buf, $off);
} elseif ($off === null && $len !== null) {
$data = substr($buf, 0, $len);
} else {
$data = substr($buf, $off, $len);
}
$this->stream .= $data;
}
/**
* {@inheritdoc}
*/
public function close()
{
$this->stream = null;
}
/**
* {@inheritdoc}
*/
public function flush()
{
echo $this->stream;
}
}