1 | <?php |
||
10 | abstract class OutputStream |
||
11 | { |
||
12 | /** |
||
13 | * @var mixed 出力ストリーム |
||
14 | */ |
||
15 | protected $stream; |
||
16 | |||
17 | /** |
||
18 | * constructor |
||
19 | * @param mixed $stream 出力ストリーム |
||
20 | */ |
||
21 | public function __construct($stream) |
||
22 | { |
||
23 | $this->stream = $stream; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * destructor |
||
28 | */ |
||
29 | public function __destruct() |
||
30 | { |
||
31 | $this->close(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * 出力ストリームに書き出す |
||
36 | * @param mixed $buf 出力データ |
||
37 | * @param int $off データ開始位置 |
||
38 | * @param int $len 書き出すバイト数 |
||
39 | * @throws WebStream\Exception\Extend\IOException |
||
40 | */ |
||
41 | abstract public function write($buf, int $off = null, int $len = null); |
||
42 | |||
43 | /** |
||
44 | * バッファリングしているすべての出力バイトを書き出し、出力ストリームを閉じる |
||
45 | * @throws WebStream\Exception\Extend\IOException |
||
46 | */ |
||
47 | abstract public function close(); |
||
48 | |||
49 | /** |
||
50 | * バッファリングしているすべての出力バイトを出力ストリームを閉じずに強制的に書き出す |
||
51 | * writeを実行した時点では書き出されておらず、flushした時点ですべて書き出す |
||
52 | * @throws WebStream\Exception\Extend\IOException |
||
53 | */ |
||
54 | abstract public function flush(); |
||
55 | } |
||
56 |