| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | class GridFile extends SplFileObject |
||
| 23 | { |
||
| 24 | public function __construct(string $filename) |
||
| 25 | { |
||
| 26 | if (str_ends_with($filename, '.zip')) { |
||
| 27 | $zip = new ZipArchive(); |
||
| 28 | $zip->open($filename); |
||
| 29 | $filename = sys_get_temp_dir() . '/' . $zip->getNameIndex(0); // only 1 file inside |
||
| 30 | |||
| 31 | if (!file_exists($filename)) { |
||
| 32 | $zip->extractTo(sys_get_temp_dir()); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | parent::__construct($filename); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function fgets(): string |
||
| 40 | { |
||
| 41 | $result = parent::fgets(); |
||
| 42 | assert($result !== false); |
||
| 43 | |||
| 44 | return $result; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function fread(int $length): string |
||
| 53 | } |
||
| 54 | } |
||
| 55 |