| 1 | <?php |
||
| 18 | class StringReader |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var StreamInterface |
||
| 22 | */ |
||
| 23 | protected $stream; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var int |
||
| 27 | */ |
||
| 28 | protected $length; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Create string reader object |
||
| 32 | * |
||
| 33 | * @throws Exception\InvalidArgumentException An exception will be thrown for non-readable streams |
||
| 34 | * |
||
| 35 | * @param StreamInterface $stream |
||
| 36 | * @param int $length |
||
| 37 | */ |
||
| 38 | 9 | public function __construct(StreamInterface $stream, $length) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * Get stream |
||
| 50 | * |
||
| 51 | * @return StreamInterface |
||
| 52 | */ |
||
| 53 | 3 | public function getStream() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Get length |
||
| 60 | * |
||
| 61 | * @return int |
||
| 62 | */ |
||
| 63 | 3 | public function getLength() |
|
| 67 | |||
| 68 | /** |
||
| 69 | * Read string data from the stream |
||
| 70 | * |
||
| 71 | * @throws Exception\IOException An exception will be thrown for invalid stream resources or when the data could |
||
| 72 | * not be read |
||
| 73 | * |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | 3 | public function read() |
|
| 80 | } |
||
| 81 |