DumpAutoload   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 35
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A optimize() 7 7 2
A run() 6 6 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 Robo\Task\Composer;
4
5
/**
6
 * Composer Dump Autoload
7
 *
8
 * ``` php
9
 * <?php
10
 * // simple execution
11
 * $this->taskComposerDumpAutoload()->run();
12
 *
13
 * // dump auto loader with custom path
14
 * $this->taskComposerDumpAutoload('path/to/my/composer.phar')
15
 *      ->preferDist()
16
 *      ->run();
17
 *
18
 * // optimize autoloader dump with custom path
19
 * $this->taskComposerDumpAutoload('path/to/my/composer.phar')
20
 *      ->optimize()
21
 *      ->run();
22
 *
23
 * // optimize autoloader dump with custom path and no dev
24
 * $this->taskComposerDumpAutoload('path/to/my/composer.phar')
25
 *      ->optimize()
26
 *      ->noDev()
27
 *      ->run();
28
 * ?>
29
 * ```
30
 */
31 View Code Duplication
class DumpAutoload extends Base
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...
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected $action = 'dump-autoload';
37
38
    /**
39
     * @var string
40
     */
41
    protected $optimize;
42
43
    /**
44
     * @param bool $optimize
45
     *
46
     * @return $this
47
     */
48
    public function optimize($optimize = true)
49
    {
50
        if ($optimize) {
51
            $this->option("--optimize");
52
        }
53
        return $this;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function run()
60
    {
61
        $command = $this->getCommand();
62
        $this->printTaskInfo('Dumping Autoloader: {command}', ['command' => $command]);
63
        return $this->executeCommand($command);
64
    }
65
}
66