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/RenderGzipFileStream.php 1 location

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

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
    {