1 | <?php |
||
2 | |||
3 | namespace Sludio\HelperBundle\Sitemap\Dumper; |
||
4 | |||
5 | class GzFileDumper implements DumperFileInterface |
||
6 | { |
||
7 | use FileDumperTrait; |
||
8 | |||
9 | /** |
||
10 | * {@inheritdoc} |
||
11 | */ |
||
12 | public function dump($string) |
||
13 | { |
||
14 | if ($this->handle === null) { |
||
15 | $this->openFile(); |
||
16 | } |
||
17 | |||
18 | gzwrite($this->handle, $string); |
||
19 | } |
||
20 | |||
21 | protected function openFile() |
||
22 | { |
||
23 | $this->handle = gzopen($this->filename, 'w9'); |
||
24 | |||
25 | if ($this->handle === false) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
26 | throw new \RuntimeException(sprintf('Impossible to open the file %s in write mode', $this->filename)); |
||
27 | } |
||
28 | } |
||
29 | } |
||
30 |