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 | * Get stream |
||
32 | * |
||
33 | * @throws Exception\BadMethodCallException An exception will be thrown when the stream was not set |
||
34 | * |
||
35 | * @return StreamInterface |
||
36 | */ |
||
37 | 9 | public function getStream() |
|
45 | |||
46 | /** |
||
47 | * Set stream |
||
48 | * |
||
49 | * @param StreamInterface $stream |
||
50 | * |
||
51 | * @throws Exception\BadMethodCallException An exception will be thrown for non-readable streams |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | 9 | public function setStream(StreamInterface $stream) |
|
65 | |||
66 | /** |
||
67 | * Get length |
||
68 | * |
||
69 | * @throws Exception\BadMethodCallException An exception will be thrown when the length was not set |
||
70 | * |
||
71 | * @return int |
||
72 | */ |
||
73 | 9 | public function getLength() |
|
81 | |||
82 | /** |
||
83 | * Set length |
||
84 | * |
||
85 | * @param int $length |
||
86 | * |
||
87 | * @return $this |
||
88 | */ |
||
89 | 6 | public function setLength($length) |
|
95 | |||
96 | /** |
||
97 | * Read string data from the stream |
||
98 | * |
||
99 | * @throws Exception\BadMethodCallException An exception will be thrown when the stream or length was not set |
||
100 | * @throws Exception\IOException An exception will be thrown for invalid stream resources or when the |
||
101 | * data could not be read |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | 3 | public function read() |
|
112 | } |
||
113 |