Code Duplication    Length = 16-17 lines in 3 locations

src/Stream/RenderBzip2FileStream.php 1 location

@@ 91-106 (lines=16) @@
88
        $this->end_string = $this->render->end();
89
    }
90
91
    public function close()
92
    {
93
        $this->state->close();
94
        $this->write($this->end_string);
95
        bzclose($this->handle);
96
97
        if (!rename($this->tmp_filename, $this->filename)) {
98
            unlink($this->tmp_filename);
99
100
            throw FileAccessException::failedOverwrite($this->tmp_filename, $this->filename);
101
        }
102
103
        $this->handle = null;
104
        $this->tmp_filename = '';
105
        $this->counter = 0;
106
    }
107
108
    /**
109
     * @param Url $url

src/Stream/RenderFileStream.php 1 location

@@ 96-112 (lines=17) @@
93
        $this->end_string = $this->render->end();
94
    }
95
96
    public function close()
97
    {
98
        $this->state->close();
99
        $this->write($this->end_string);
100
        fclose($this->handle);
101
102
        if (!rename($this->tmp_filename, $this->filename)) {
103
            unlink($this->tmp_filename);
104
105
            throw FileAccessException::failedOverwrite($this->tmp_filename, $this->filename);
106
        }
107
108
        $this->handle = null;
109
        $this->tmp_filename = '';
110
        $this->counter = 0;
111
        $this->used_bytes = 0;
112
    }
113
114
    /**
115
     * @param Url $url

src/Stream/RenderGzipFileStream.php 1 location

@@ 102-117 (lines=16) @@
99
        $this->end_string = $this->render->end();
100
    }
101
102
    public function close()
103
    {
104
        $this->state->close();
105
        $this->write($this->end_string);
106
        gzclose($this->handle);
107
108
        if (!rename($this->tmp_filename, $this->filename)) {
109
            unlink($this->tmp_filename);
110
111
            throw FileAccessException::failedOverwrite($this->tmp_filename, $this->filename);
112
        }
113
114
        $this->handle = null;
115
        $this->tmp_filename = '';
116
        $this->counter = 0;
117
    }
118
119
    /**
120
     * @param Url $url