Completed
Push — master ( d87b02...4573bb )
by Harry
04:40
created

Gzip::getName()   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 0
crap 1
1
<?php
1 ignored issue
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 32 and the first side effect is on line 12.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Graze\DataFile\Modify\Compress;
4
5
use Graze\DataFile\Helper\GetOptionTrait;
6
use Graze\DataFile\Helper\OptionalLoggerTrait;
7
use Graze\DataFile\Helper\Process\ProcessFactoryAwareInterface;
8
use Graze\DataFile\Modify\FileProcessTrait;
9
use Graze\DataFile\Node\LocalFileNodeInterface;
10
use Psr\Log\LoggerAwareInterface;
11
12 View Code Duplication
class Gzip implements
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...
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
13
    CompressionTypeInterface,
14
    CompressorInterface,
15
    DeCompressorInterface,
16
    LoggerAwareInterface,
17
    ProcessFactoryAwareInterface
18
{
19
    use GetOptionTrait;
20
    use FileProcessTrait;
21
    use OptionalLoggerTrait;
22
    use CompressorTrait;
23
    use DeCompressorTrait;
24
25
    const NAME = 'gzip';
26
27
    /**
28
     * Get the extension used by this compressor
29
     *
30
     * @return string
31
     */
32 10
    public function getExtension()
33
    {
34 10
        return 'gz';
35
    }
36
37
    /**
38
     * @return string
39
     */
40 22
    public function getName()
41
    {
42 22
        return static::NAME;
43
    }
44
45
    /**
46
     * Get the command line to compress a file
47
     *
48
     * @param LocalFileNodeInterface $from
49
     * @param LocalFileNodeInterface $to
50
     *
51
     * @return string
52
     */
53 10
    public function getCompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $to. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
54
    {
55 10
        return sprintf("gzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
56
    }
57
58
    /**
59
     * Get the command line to decompress a file
60
     *
61
     * @param LocalFileNodeInterface $from
62
     * @param LocalFileNodeInterface $to
63
     *
64
     * @return string
65
     */
66 6
    public function getDecompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $to. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
67
    {
68 6
        return sprintf("gunzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
69
    }
70
}
71