Gzip   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtension() 4 4 1
A getName() 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
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Modify\Compress;
15
16
use Graze\DataFile\Helper\Builder\BuilderAwareInterface;
17
use Graze\DataFile\Helper\GetOptionTrait;
18
use Graze\DataFile\Helper\OptionalLoggerTrait;
19
use Graze\DataFile\Modify\FileProcessTrait;
20
use Graze\DataFile\Node\LocalFileNodeInterface;
21
use Psr\Log\LoggerAwareInterface;
22
23 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...
24
    CompressionTypeInterface,
25
    CompressorInterface,
26
    DeCompressorInterface,
27
    LoggerAwareInterface,
28
    BuilderAwareInterface
29
{
30
    use GetOptionTrait;
31
    use FileProcessTrait;
32
    use OptionalLoggerTrait;
33
    use CompressorTrait;
34
    use DeCompressorTrait;
35
36
    const NAME = 'gzip';
37
38
    /**
39
     * Get the extension used by this compressor
40
     *
41
     * @return string
42
     */
43 11
    public function getExtension()
44
    {
45 11
        return 'gz';
46
    }
47
48
    /**
49
     * @return string
50
     */
51 21
    public function getName()
52
    {
53 21
        return static::NAME;
54
    }
55
56
    /**
57
     * Get the command line to compress a file
58
     *
59
     * @param LocalFileNodeInterface $from
60
     * @param LocalFileNodeInterface $to
61
     *
62
     * @return string
63
     */
64 11
    public function getCompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
65
    {
66 11
        return sprintf("gzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
67
    }
68
69
    /**
70
     * Get the command line to decompress a file
71
     *
72
     * @param LocalFileNodeInterface $from
73
     * @param LocalFileNodeInterface $to
74
     *
75
     * @return string
76
     */
77 6
    public function getDecompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
78
    {
79 6
        return sprintf("gunzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
80
    }
81
}
82