Completed
Push — 2.0 ( ee0168...76e968 )
by Marco
11:26
created

AbstractTask   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 5
dl 0
loc 96
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A getName() 0 5 1
A getParameters() 0 5 1
A setName() 0 7 1
A setParameters() 0 7 1
run() 0 1 ?
1
<?php namespace Comodojo\Extender\Task;
2
3
use \Comodojo\Foundation\Base\Configuration;
4
use \Comodojo\Extender\Interfaces\TaskInterface;
5
use \Comodojo\Extender\Traits\ConfigurationTrait;
6
use \Comodojo\Daemon\Traits\LoggerTrait;
7
use \Comodojo\Daemon\Traits\PidTrait;
8
use \Comodojo\Daemon\Traits\EventsTrait;
9
use \Comodojo\Daemon\Utils\ProcessTools;
10
use \Psr\Log\LoggerInterface;
11
use \Comodojo\Foundation\Events\Manager as EventsManager;
12
13
/**
14
* @package     Comodojo Extender
15
* @author      Marco Giovinazzi <[email protected]>
16
* @license     MIT
17
*
18
* LICENSE:
19
*
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
* THE SOFTWARE.
27
 */
28
29
abstract class AbstractTask implements TaskInterface {
30
31
    use ConfigurationTrait;
32
    use EventsTrait;
33
    use LoggerTrait;
34
    use PidTrait;
35
36
    /**
37
     * @var string
38
     */
39
    protected $name;
40
41
    /**
42
     * @var TaskParameters
43
     */
44
    protected $parameters;
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function __construct(
50
        Configuration $configuration,
51
        EventsManager $events,
52
        LoggerInterface $logger,
53
        $name,
54
        TaskParameters $parameters
55
    ) {
56
57
        // Setup task
58
        $this->setConfiguration($configuration);
59
        $this->setEvents($events);
60
        $this->setLogger($logger);
61
        $this->setName($name);
62
        $this->setParameters($parameters);
63
        $this->setPid(ProcessTools::getPid());
64
65
    }
66
67
    /**
68
     * Get niceness of a running process
69
     *
70
     * @param int|null $pid The pid to query, or current process if null
0 ignored issues
show
Bug introduced by
There is no parameter named $pid. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
71
     * @return int
72
     */
73
    public function getName() {
74
75
        return $this->name;
76
77
    }
78
79
    /**
80
     * Get niceness of a running process
81
     *
82
     * @param int|null $pid The pid to query, or current process if null
0 ignored issues
show
Bug introduced by
There is no parameter named $pid. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
83
     * @return int
84
     */
85
    public function getParameters() {
86
87
        return $this->parameters;
88
89
    }
90
91
    /**
92
     * Get niceness of a running process
93
     *
94
     * @param int|null $pid The pid to query, or current process if null
0 ignored issues
show
Bug introduced by
There is no parameter named $pid. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
95
     * @return int
96
     */
97
    public function setName($name) {
98
99
        $this->name = $name;
100
101
        return $this;
102
103
    }
104
105
    /**
106
     * Get niceness of a running process
107
     *
108
     * @param int|null $pid The pid to query, or current process if null
0 ignored issues
show
Bug introduced by
There is no parameter named $pid. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
109
     * @return int
110
     */
111
    public function setParameters(TaskParameters $parameters) {
112
113
        $this->parameters = $parameters;
114
115
        return $this;
116
117
    }
118
119
    /**
120
     * The run method; SHOULD be implemented by each task
121
     */
122
    abstract public function run();
123
124
}
125