| @@ 11-40 (lines=30) @@ | ||
| 8 | * @package Balloon\Proxy |
|
| 9 | * @author Raphaël Lefebvre <[email protected]> |
|
| 10 | */ |
|
| 11 | class FileReaderCache implements IFileReader |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var mixed |
|
| 15 | */ |
|
| 16 | private $content; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @return mixed |
|
| 20 | */ |
|
| 21 | public function read() |
|
| 22 | { |
|
| 23 | return $this->content; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param mixed $data |
|
| 28 | * @param int $mode |
|
| 29 | * @return int |
|
| 30 | */ |
|
| 31 | public function write($data, $mode = 0) |
|
| 32 | { |
|
| 33 | if(is_string($data) && $mode & FILE_APPEND){ |
|
| 34 | $this->content .= $data; |
|
| 35 | }else{ |
|
| 36 | $this->content = $data; |
|
| 37 | } |
|
| 38 | return 0; |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 9-38 (lines=30) @@ | ||
| 6 | * @package Balloon\Reader |
|
| 7 | * @author Raphaël Lefebvre <[email protected]> |
|
| 8 | */ |
|
| 9 | class DummyFileReader implements IFileReader |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var string |
|
| 13 | */ |
|
| 14 | private $content = ''; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @return string |
|
| 18 | */ |
|
| 19 | public function read() |
|
| 20 | { |
|
| 21 | return $this->content; |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param string $data |
|
| 26 | * @param int $mode |
|
| 27 | * @return int |
|
| 28 | */ |
|
| 29 | public function write($data, $mode = 0) |
|
| 30 | { |
|
| 31 | if($mode & FILE_APPEND){ |
|
| 32 | $this->content .= $data; |
|
| 33 | }else{ |
|
| 34 | $this->content = $data; |
|
| 35 | } |
|
| 36 | return strlen($data); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||