Code Duplication    Length = 20-20 lines in 2 locations

src/Webcreate/Conveyor/Transporter/RsyncTransporter.php 1 location

@@ 146-165 (lines=20) @@
143
     * @param  string            $dest    remote destination path
144
     * @throws \RuntimeException
145
     */
146
    public function putContent($content, $dest)
147
    {
148
        $temp_file = tempnam(sys_get_temp_dir(), 'rsync' . time());
149
150
        file_put_contents($temp_file, $content);
151
152
        $commandline = sprintf("rsync -a \"%s\" '%s@%s:%s'", $temp_file, $this->getUser(), $this->getHost(), $dest);
153
154
        $this->_exists[$dest] = true;
155
156
        $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_PUT_CONTENT, new TransporterEvent($this, array('dest' => $dest, 'src' => $temp_file, 'content' => $content)));
157
158
        if ($this->cli->execute($commandline)) {
159
            @unlink($temp_file);
160
161
            throw new \RuntimeException($this->cli->getErrorOutput());
162
        }
163
164
        @unlink($temp_file);
165
    }
166
167
    /**
168
     * Creates a symlink on the remote server

src/Webcreate/Conveyor/Transporter/ScpTransporter.php 1 location

@@ 145-164 (lines=20) @@
142
     * @param  string            $dest    remote destination path
143
     * @throws \RuntimeException
144
     */
145
    public function putContent($content, $dest)
146
    {
147
        $temp_file = tempnam(sys_get_temp_dir(), 'rsync' . time());
148
149
        file_put_contents($temp_file, $content);
150
151
        $commandline = sprintf("scp \"%s\" '%s@%s:%s'", $temp_file, $this->getUser(), $this->getHost(), $dest);
152
153
        $this->_exists[$dest] = true;
154
155
        $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_PUT_CONTENT, new TransporterEvent($this, array('dest' => $dest, 'src' => $temp_file, 'content' => $content)));
156
157
        if ($this->cli->execute($commandline)) {
158
            @unlink($temp_file);
159
160
            throw new \RuntimeException($this->cli->getErrorOutput());
161
        }
162
163
        @unlink($temp_file);
164
    }
165
166
    /**
167
     * Creates a symlink on the remote server