Code Duplication    Length = 12-14 lines in 3 locations

src/Stream/RenderFileStream.php 1 location

@@ 81-94 (lines=14) @@
78
        return $this->filename;
79
    }
80
81
    public function open()
82
    {
83
        $this->state->open();
84
85
        $this->tmp_filename = tempnam(sys_get_temp_dir(), 'sitemap');
86
87
        if (($this->handle = @fopen($this->tmp_filename, 'wb')) === false) {
88
            throw FileAccessException::notWritable($this->tmp_filename);
89
        }
90
91
        $this->write($this->render->start());
92
        // render end string only once
93
        $this->end_string = $this->render->end();
94
    }
95
96
    public function close()
97
    {

src/Stream/RenderIndexFileStream.php 1 location

@@ 94-105 (lines=12) @@
91
        return $this->filename;
92
    }
93
94
    public function open()
95
    {
96
        $this->state->open();
97
        $this->substream->open();
98
99
        $this->tmp_filename = tempnam(sys_get_temp_dir(), 'sitemap_index');
100
        if (($this->handle = @fopen($this->tmp_filename, 'wb')) === false) {
101
            throw FileAccessException::notWritable($this->tmp_filename);
102
        }
103
104
        fwrite($this->handle, $this->render->start());
105
    }
106
107
    public function close()
108
    {

src/Stream/RenderGzipFileStream.php 1 location

@@ 93-106 (lines=14) @@
90
        return $this->filename;
91
    }
92
93
    public function open()
94
    {
95
        $this->state->open();
96
97
        $mode = 'wb'.$this->compression_level;
98
        $this->tmp_filename = tempnam(sys_get_temp_dir(), 'sitemap');
99
        if (($this->handle = @gzopen($this->tmp_filename, $mode)) === false) {
100
            throw FileAccessException::notWritable($this->tmp_filename);
101
        }
102
103
        $this->write($this->render->start());
104
        // render end string only once
105
        $this->end_string = $this->render->end();
106
    }
107
108
    public function close()
109
    {