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

Zip::compress()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 26
Code Lines 16

Duplication

Lines 26
Ratio 100 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 26
loc 26
ccs 15
cts 15
cp 1
rs 8.8571
cc 3
eloc 16
nc 3
nop 2
crap 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Zip::getCompressCommand() 4 4 1
A Zip::getDecompressCommand() 4 4 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