| Total Complexity | 7 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class NoneCompressor extends Factory |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var false|resource |
||
| 20 | */ |
||
| 21 | private $handler; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritDoc} |
||
| 25 | */ |
||
| 26 | public function open(string $filename, string $mode = 'wb'): bool |
||
| 27 | { |
||
| 28 | $this->handler = fopen($filename, $mode); |
||
| 29 | if (false === $this->handler) { |
||
| 30 | throw Exception::fileNotWritable($filename); |
||
| 31 | } |
||
| 32 | |||
| 33 | return true; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritDoc} |
||
| 38 | */ |
||
| 39 | public function write(string $data): int |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritDoc} |
||
| 52 | */ |
||
| 53 | public function read(): string |
||
| 54 | { |
||
| 55 | $content = ''; |
||
| 56 | |||
| 57 | while (! feof($this->handler)) { |
||
| 58 | // Read buffer-size bytes |
||
| 59 | $content .= fread($this->handler, 4096); // read 4kb at a time |
||
| 60 | } |
||
| 61 | |||
| 62 | return $content; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * {@inheritDoc} |
||
| 67 | */ |
||
| 68 | public function close(): bool |
||
| 71 | } |
||
| 72 | } |
||
| 73 |