Completed
Push — master ( a15851...522585 )
by Harry
02:42
created

Zip::getDecompressCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Graze\DataFile\Modify\Compress;
4
5 View Code Duplication
class Zip extends AbstractCompressor
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    /**
8
     * Get the extension used by this compressor
9
     *
10
     * @return string
11
     */
12 6
    protected function getExtension()
13
    {
14 6
        return 'zip';
15
    }
16
17
    /**
18
     * @return string
19
     */
20 7
    protected function getCompression()
21
    {
22 7
        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 6
    protected function getCompressCommand($fromPath, $toPath)
34
    {
35 6
        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 4
    protected function getDecompressCommand($fromPath, $toPath)
47
    {
48 4
        return sprintf("unzip -p %s > %s", escapeshellarg($fromPath), escapeshellarg($toPath));
49
    }
50
}
51