1 | <?php |
||
31 | trait IsWritable |
||
32 | { |
||
33 | /** |
||
34 | * Write single line to file/stream. |
||
35 | * |
||
36 | * Writes a line to the file/stream (if it is writable) |
||
37 | * |
||
38 | * @param string $line The line to be written to the stream |
||
39 | * @param string $eol The end of line string |
||
40 | * |
||
41 | * @throws IOException |
||
42 | * |
||
43 | * @return int The number of bytes written to the stream |
||
44 | */ |
||
45 | 15 | public function writeLine($line, $eol = PHP_EOL) |
|
46 | { |
||
47 | 15 | return $this->write($line . $eol); |
|
48 | } |
||
49 | |||
50 | abstract public function isWritable(); |
||
51 | |||
52 | abstract public function write($str); |
||
53 | |||
54 | /** |
||
55 | * Assert that this file/stream object is readable. |
||
56 | * |
||
57 | * @throws IOException |
||
58 | */ |
||
59 | 18 | protected function assertIsWritable() |
|
65 | } |
||
66 |