add IO test
[m6w6/atick] / lib / atick / IO.php
1 <?php
2
3 namespace atick\IO;
4
5 function copy($from, $to, $len = 4096) {
6 $data = fread($from, $len);
7
8 if (!strlen($data)) {
9 if (feof($from)) {
10 /* forward EOF */
11 fclose($to);
12 }
13 return;
14 }
15
16 return fwrite($to, $data);
17 }
18
19 namespace atick;
20
21 interface IO
22 {
23 /**
24 * Retrieve the output stream
25 * @return resource
26 */
27 function getOutput();
28
29 /**
30 * Retrieve the input stream
31 * @return resource
32 */
33 function getInput();
34
35 /**
36 * Pass input from FD to input and return output stream
37 * @param resource $fd
38 * @return resource
39 */
40 function __invoke($fd);
41 }