Completed
Push — master ( 799de4...6f590f )
by Aitor
10s
created

Reload::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of RoboSystemService.
4
 *
5
 * @author      Polyvaniy Oleksii (alexndlm) <[email protected]>
6
 * @copyright   2016 Polyvaniy Oleksii (alexndlm) <[email protected]>
7
 *
8
 * @license     MIT
9
 */
10
11
namespace Falc\Robo\Service;
12
13
use Robo\Contract\CommandInterface;
14
15
/**
16
 * Service reload
17
 *
18
 * ``` php
19
 * // Reloading a service:
20
 * $this->taskServiceReload()
21
 *     ->serviceManager('systemd')
22
 *     ->service('httpd')
23
 *     ->run();
24
 *
25
 * // Compact form:
26
 * $this->taskServiceReload('systemd', 'httpd')->run();
27
 * ```
28
 */
29 View Code Duplication
class Reload extends BaseTask implements CommandInterface
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...
30
{
31
    /**
32
     * {@inheritdoc}
33
     *
34
     * @throws \InvalidArgumentException
35
     */
36 7
    public function getCommand()
37
    {
38 7
        if ($this->builder === null) {
39 1
            throw new \InvalidArgumentException('Service manager not defined');
40
        }
41
42 6
        $this->builder->reload($this->service);
43
44 6
        if (!$this->verbose) {
45 5
            $this->builder->quiet();
46 5
        }
47
48 6
        return $this->builder->getCommand();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     *
54
     * @throws \InvalidArgumentException
55
     */
56 1
    public function run()
57
    {
58 1
        $command = $this->getCommand();
59
60 1
        $this->printTaskInfo('Reloading service...');
61 1
        return $this->executeCommand($command);
62
    }
63
}
64