1 | <?php |
||
5 | class StreamBuffer implements BufferInterface |
||
6 | { |
||
7 | const READ_LENGTH = 128; |
||
8 | |||
9 | /** @var string */ |
||
10 | protected $contents; |
||
11 | /** @var int */ |
||
12 | protected $length; |
||
13 | /** @var int */ |
||
14 | protected $position; |
||
15 | /** @var bool */ |
||
16 | protected $eof = false; |
||
17 | /** @var int */ |
||
18 | protected $minSize; |
||
19 | |||
20 | /** @var resource */ |
||
21 | private $stream; |
||
22 | /** @var int */ |
||
23 | private $readLength; |
||
24 | |||
25 | /** |
||
26 | * Create a buffer around a stream |
||
27 | * |
||
28 | * @param resource $stream |
||
29 | * @param int $readLength |
||
30 | * @param int $minSize |
||
31 | */ |
||
32 | 34 | public function __construct($stream, $readLength = self::READ_LENGTH, $minSize = -1) |
|
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | 32 | public function getContents() |
|
49 | |||
50 | /** |
||
51 | * @return int |
||
52 | */ |
||
53 | 29 | public function getLength() |
|
57 | |||
58 | /** |
||
59 | * @return bool |
||
60 | */ |
||
61 | 31 | public function isEof() |
|
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | */ |
||
69 | 34 | public function read() |
|
85 | |||
86 | /** |
||
87 | * Remove the first $length characters from the buffer |
||
88 | * |
||
89 | * @param int $length |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | 29 | public function move($length) |
|
101 | |||
102 | /** |
||
103 | * @return bool |
||
104 | */ |
||
105 | 1 | public function isSourceEof() |
|
109 | |||
110 | /** |
||
111 | * @return int |
||
112 | */ |
||
113 | 29 | public function getPosition() |
|
117 | |||
118 | /** |
||
119 | * @return int |
||
120 | */ |
||
121 | 1 | public function getMinBufferSize() |
|
125 | |||
126 | /** |
||
127 | * @param int $size |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | 4 | public function setMinBufferSize($size) |
|
136 | } |
||
137 |