Code Duplication    Length = 46-46 lines in 2 locations

src/Modify/Compress/Gzip.php 1 location

@@ 5-50 (lines=46) @@
2
3
namespace Graze\DataFile\Modify\Compress;
4
5
class Gzip extends AbstractCompressor
6
{
7
    /**
8
     * Get the extension used by this compressor
9
     *
10
     * @return string
11
     */
12
    protected function getExtension()
13
    {
14
        return 'gz';
15
    }
16
17
    /**
18
     * @return string
19
     */
20
    protected function getCompression()
21
    {
22
        return CompressionType::GZIP;
23
    }
24
25
    /**
26
     * Get the command line to compress a file
27
     *
28
     * @param string $fromPath
29
     * @param string $toPath
30
     *
31
     * @return string
32
     */
33
    protected function getCompressCommand($fromPath, $toPath)
34
    {
35
        return sprintf("gzip -c %s > %s", escapeshellarg($fromPath), escapeshellarg($toPath));
36
    }
37
38
    /**
39
     * Get the command line to decompress a file
40
     *
41
     * @param string $fromPath
42
     * @param string $toPath
43
     *
44
     * @return string
45
     */
46
    protected function getDecompressCommand($fromPath, $toPath)
47
    {
48
        return sprintf("gunzip -c %s > %s", escapeshellarg($fromPath), escapeshellarg($toPath));
49
    }
50
}
51

src/Modify/Compress/Zip.php 1 location

@@ 5-50 (lines=46) @@
2
3
namespace Graze\DataFile\Modify\Compress;
4
5
class Zip extends AbstractCompressor
6
{
7
    /**
8
     * Get the extension used by this compressor
9
     *
10
     * @return string
11
     */
12
    protected function getExtension()
13
    {
14
        return 'zip';
15
    }
16
17
    /**
18
     * @return string
19
     */
20
    protected function getCompression()
21
    {
22
        return CompressionType::ZIP;
23
    }
24
25
    /**
26
     * Get the command line to compress a file
27
     *
28
     * @param string $fromPath
29
     * @param string $toPath
30
     *
31
     * @return string
32
     */
33
    protected function getCompressCommand($fromPath, $toPath)
34
    {
35
        return sprintf("zip %s %s", escapeshellarg($toPath), escapeshellarg($fromPath));
36
    }
37
38
    /**
39
     * Get the command line to decompress a file
40
     *
41
     * @param string $fromPath
42
     * @param string $toPath
43
     *
44
     * @return string
45
     */
46
    protected function getDecompressCommand($fromPath, $toPath)
47
    {
48
        return sprintf("unzip -p %s > %s", escapeshellarg($fromPath), escapeshellarg($toPath));
49
    }
50
}
51