Code Duplication    Length = 9-12 lines in 5 locations

src/Gaufrette/Adapter/Sftp.php 2 locations

@@ 44-52 (lines=9) @@
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function rename($sourceKey, $targetKey)
45
    {
46
        $sourcePath = $this->computePath($sourceKey);
47
        $targetPath = $this->computePath($targetKey);
48
49
        $this->ensureDirectoryExists(\Gaufrette\Util\Path::dirname($targetPath), true);
50
51
        return $this->sftp->rename($sourcePath, $targetPath);
52
    }
53
54
    /**
55
     * {@inheritdoc}
@@ 57-66 (lines=10) @@
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function write($key, $content)
58
    {
59
        $this->initialize();
60
61
        $path = $this->computePath($key);
62
        $this->ensureDirectoryExists(\Gaufrette\Util\Path::dirname($path), true);
63
        $numBytes = $this->sftp->write($path, $content);
64
65
        return $numBytes;
66
    }
67
68
    /**
69
     * {@inheritdoc}

src/Gaufrette/Adapter/PhpseclibSftp.php 2 locations

@@ 43-53 (lines=11) @@
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function rename($sourceKey, $targetKey)
44
    {
45
        $this->initialize();
46
47
        $sourcePath = $this->computePath($sourceKey);
48
        $targetPath = $this->computePath($targetKey);
49
50
        $this->ensureDirectoryExists(\Gaufrette\Util\Path::dirname($targetPath), true);
51
52
        return $this->sftp->rename($sourcePath, $targetPath);
53
    }
54
55
    /**
56
     * {@inheritdoc}
@@ 58-69 (lines=12) @@
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function write($key, $content)
59
    {
60
        $this->initialize();
61
62
        $path = $this->computePath($key);
63
        $this->ensureDirectoryExists(\Gaufrette\Util\Path::dirname($path), true);
64
        if ($this->sftp->put($path, $content)) {
65
            return $this->sftp->size($path);
66
        }
67
68
        return false;
69
    }
70
71
    /**
72
     * {@inheritdoc}

src/Gaufrette/Adapter/Ftp.php 1 location

@@ 104-114 (lines=11) @@
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function rename($sourceKey, $targetKey)
105
    {
106
        $this->ensureDirectoryExists($this->directory, $this->create);
107
108
        $sourcePath = $this->computePath($sourceKey);
109
        $targetPath = $this->computePath($targetKey);
110
111
        $this->ensureDirectoryExists(\Gaufrette\Util\Path::dirname($targetPath));
112
113
        return ftp_rename($this->getConnection(), $sourcePath, $targetPath);
114
    }
115
116
    /**
117
     * {@inheritdoc}