SysVinitRedHatCommandBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 34
loc 34
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enable() 12 12 2
A disable() 12 12 2

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      Aitor García Martínez (Falc) <[email protected]>
6
 * @copyright   2016 Aitor García Martínez (Falc) <[email protected]>
7
 *
8
 * @author      Polyvaniy Oleksii (alexndlm) <[email protected]>
9
 * @copyright   2016 Polyvaniy Oleksii (alexndlm) <[email protected]>
10
 *
11
 * @license     MIT
12
 */
13
14
namespace Falc\Robo\Service\CommandBuilder;
15
16
/**
17
 * SysVinit command builder for Red Hat based distros.
18
 */
19 View Code Duplication
class SysVinitRedHatCommandBuilder extends SysVinitCommandBuilder
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...
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function enable($service)
25
    {
26 2
        if (empty($service)) {
27 1
            throw new \InvalidArgumentException('No service selected to be enabled');
28
        }
29
30 1
        $this->cmd = 'chkconfig';
31 1
        $this->service = $service;
32 1
        $this->action = 'on';
33
34 1
        return $this;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function disable($service)
41
    {
42 2
        if (empty($service)) {
43 1
            throw new \InvalidArgumentException('No service selected to be disabled');
44
        }
45
46 1
        $this->cmd = 'chkconfig';
47 1
        $this->service = $service;
48 1
        $this->action = 'off';
49
50 1
        return $this;
51
    }
52
}
53