StepPush   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 10
Bugs 0 Features 6
Metric Value
wmc 5
c 10
b 0
f 6
lcom 1
cbo 1
dl 0
loc 77
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A getCommand() 0 20 4
1
<?php
2
/**
3
 * Step to push application into a Cloud Foundry instance.
4
 */
5
6
namespace Graviton\Deployment\Steps\CloudFoundry;
7
8
/**
9
 * @author   List of contributors <https://github.com/libgraviton/deploy-scripts/graphs/contributors>
10
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
11
 * @link     http://swisscom.ch
12
 */
13
final class StepPush extends AbstractCommonStep
14
{
15
    /**
16
     * indicate if --no-start flag is to be used or not
17
     *
18
     * @var boolean
19
     */
20
    protected $start;
21
22
    /**
23
     * indicate if --no-route flag is to be used or not
24
     *
25
     * @var boolean
26
     */
27
    protected $noRoute;
28
29
    /**
30
     * defines default startup command
31
     *
32
     * @var string
33
     */
34
    protected $command;
35
36
    /**
37
     * @var string Name of the step to be registered.
38
     */
39
    protected static $stepName = 'push';
40
41
    /**
42
     * @param array   $configuration   Current application configuration.
43
     * @param string  $applicationName Name of the CF-application to be checked
44
     * @param string  $slice           deployment location in blue/green deployment.
45
     * @param boolean $start           start the app on push or use --no-start flag
46
     * @param boolean $noRoute         assign a route or use --no-route flag
47
     * @param string  $command         command to be executed
48
     */
49 6
    public function __construct(
50
        array $configuration,
51
        $applicationName,
52
        $slice,
53
        $start = true,
54
        $noRoute = false,
55
        $command = ''
56
    ) {
57 6
        parent::__construct($configuration, $applicationName, $slice);
58
59 6
        $this->start = $start;
60 6
        $this->noRoute = $noRoute;
61 6
        $this->command = (string) $command;
62 6
    }
63
64
    /**
65
     * returns the command
66
     *
67
     * @return array
68
     */
69 5
    public function getCommand()
70
    {
71 5
        $command = parent::getCommand();
72
73 5
        if (!$this->start) {
74 4
            $command[] = '--no-start';
75 4
        }
76
77 5
        if ($this->noRoute) {
78 2
            $command[] = '--no-route';
79 2
        }
80
81 5
        if (!empty($this->command)) {
82
            // -c flag defines a startup command which runs when the app has started
83 2
            $command[] = '-c';
84 2
            $command[] = $this->command;
85 2
        }
86
87 5
        return $command;
88
    }
89
}
90