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

Zip   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 0
cbo 1
dl 46
loc 46
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtension() 4 4 1
A getCompression() 4 4 1
A getCompressCommand() 4 4 1
A getDecompressCommand() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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