DeployCommit   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 59
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A prepare() 0 10 2
A execute() 0 8 2
A prepareTargets() 0 4 1
A hasTargets() 0 7 2
A prepareAction() 0 6 1
1
<?php
2
/**
3
 * Estatisticas Rodadas Diariamente
4
 */
5
6
namespace Fabrica\Hook;
7
8
use Operador\Actions\Action;
9
use Operador\Actions\ActionCollection;
10
11
use Fabrica\Models\Code\Commit;
12
13
class DeployCommit extends ActionCollection
14
{
15
16
    /**
17
     * Avisa se precisa de Alvos Externos ou nao e descreve eles
18
     */
19
    public $externalTargetCounts = 1;
20
    
21
    /**
22
     * Avisa se precisa de Alvos Externos ou nao e descreve eles
23
     */
24
    public $externalTargetZeroClass = Commit::class;
25
    
26
    /**
27
     * Avisa se precisa de Alvos Externos ou nao e descreve eles
28
     */
29
    public $externalTargetZeroInstance = false;
30
31
    public function prepare()
32
    {
33
        if ($this->isPrepared) {
34
            return true;
35
        }
36
37
        $this->prepareAction();
38
39
        return parent::prepare();
40
    }
41
42
    public function execute()
43
    {
44
        if (!$this->hasTargets()) {
45
            return false;
46
        }
47
48
        return parent::execute();
49
    }
50
51
    public function prepareTargets(Commit $sshKey)
52
    {
53
        $externalTargetZeroClass = $sshKey;
0 ignored issues
show
Unused Code introduced by
$externalTargetZeroClass is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
    }
55
56
    public function hasTargets()
57
    {
58
        if ($this->externalTargetZeroInstance === false) {
59
            return false;
60
        }
61
        return true;
62
    }
63
    
64
    public function prepareAction()
65
    {
66
        $stage = 0;
67
        $action = Action::getActionByCode('updateBusinessAmbiente');
68
        $this->newAction($action, $stage, 0);
69
    }
70
71
}
72