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

Reload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 35
loc 35
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommand() 14 14 3
A run() 7 7 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
 * 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