Validate   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 82
Duplicated Lines 87.8 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 1
dl 72
loc 82
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A noCheckAll() 7 7 2
A noCheckLock() 7 7 2
A noCheckPublish() 7 7 2
A withDependencies() 7 7 2
A strict() 7 7 2
A run() 0 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 Validate
7
 *
8
 * ``` php
9
 * <?php
10
 * // simple execution
11
 * $this->taskComposerValidate()->run();
12
 * ?>
13
 * ```
14
 */
15 View Code Duplication
class Validate 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...
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $action = 'validate';
21
22
    /**
23
     * @param bool $noCheckAll
24
     *
25
     * @return $this
26
     */
27
    public function noCheckAll($noCheckAll = true)
28
    {
29
        if ($noCheckAll) {
30
            $this->option('--no-check-all');
31
        }
32
        return $this;
33
    }
34
35
    /**
36
     * @param bool $noCheckLock
37
     *
38
     * @return $this
39
     */
40
    public function noCheckLock($noCheckLock = true)
41
    {
42
        if ($noCheckLock) {
43
            $this->option('--no-check-lock');
44
        }
45
        return $this;
46
    }
47
48
    /**
49
     * @param bool $noCheckPublish
50
     *
51
     * @return $this
52
     */
53
    public function noCheckPublish($noCheckPublish = true)
54
    {
55
        if ($noCheckPublish) {
56
            $this->option('--no-check-publish');
57
        }
58
        return $this;
59
    }
60
61
    /**
62
     * @param bool $withDependencies
63
     *
64
     * @return $this
65
     */
66
    public function withDependencies($withDependencies = true)
67
    {
68
        if ($withDependencies) {
69
            $this->option('--with-dependencies');
70
        }
71
        return $this;
72
    }
73
74
    /**
75
     * @param bool $strict
76
     *
77
     * @return $this
78
     */
79
    public function strict($strict = true)
80
    {
81
        if ($strict) {
82
            $this->option('--strict');
83
        }
84
        return $this;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function run()
91
    {
92
        $command = $this->getCommand();
93
        $this->printTaskInfo('Validating composer.json: {command}', ['command' => $command]);
94
        return $this->executeCommand($command);
95
    }
96
}
97