1 | <?php |
||
22 | trait IsReadable |
||
23 | { |
||
24 | /** |
||
25 | * Read single line. |
||
26 | * Read the next line from the file (moving the internal pointer down a line). |
||
27 | * Returns multiple lines if newline character(s) fall within a quoted string. |
||
28 | * |
||
29 | * @param string|array $eol A string or array of strings to be used as EOL char/sequence |
||
30 | * @param int $maxLength Maximum number of bytes to return (line will be truncated to this -1 if set) |
||
31 | * |
||
32 | * @throws IOException |
||
33 | * |
||
34 | * @return string A single line read from the file. |
||
35 | * |
||
36 | * @todo Should this add a newline if maxlength is reached? |
||
37 | * @todo I could actually buffer this by reading x chars at a time and doing |
||
38 | * the same thing with looping char by char if this is too IO intensive. |
||
39 | */ |
||
40 | 17 | public function readLine($eol = PHP_EOL, $maxLength = null) |
|
69 | |||
70 | abstract public function isReadable(); |
||
71 | |||
72 | abstract public function read($length); |
||
73 | |||
74 | abstract public function eof(); |
||
75 | |||
76 | /** |
||
77 | * Assert that this file/stream object is readable. |
||
78 | * |
||
79 | * @throws IOException |
||
80 | */ |
||
81 | 32 | protected function assertIsReadable() |
|
87 | } |
||
88 |