Completed
Branch master (d1a89c)
by Andrés
05:54
created

AbstractTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
getName() 0 1 ?
getDescription() 0 1 ?
execute() 0 1 ?
A setRuntime() 0 5 1
A getDefaults() 0 4 1
A setOptions() 0 9 2
1
<?php
2
/*
3
 * This file is part of the Magallanes package.
4
 *
5
 * (c) Andrés Montañez <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Mage\Task;
12
13
use Mage\Runtime\Runtime;
14
15
/**
16
 * Abstract base class for Magallanes Tasks
17
 *
18
 * @author Andrés Montañez <[email protected]>
19
 */
20
abstract class AbstractTask
21
{
22
    /**
23
     * @var array Task custom options
24
     */
25
    protected $options = [];
26
27
    /**
28
     * @var Runtime
29
     */
30
    protected $runtime;
31
32
    /**
33
     * Get the Name/Code of the Task
34
     *
35
     * @return string
36
     */
37
    abstract public function getName();
38
39
    /**
40
     * Get a short Description of the Task
41
     *
42
     * @return string
43
     */
44
    abstract public function getDescription();
45
46
    /**
47
     * Executes the Command
48
     *
49
     * @return bool
50
     */
51
    abstract public function execute();
52
53
    /**
54
     * Set additional Options for the Task
55
     *
56
     * @param array $options Options
57
     * @return AbstractTask
58
     */
59 64
    public function setOptions($options = [])
60
    {
61 64
        if (!is_array($options)) {
62 1
            $options = [];
63
        }
64
65 64
        $this->options = array_merge($this->getDefaults(), $options);
66 64
        return $this;
67
    }
68
69
    /**
70
     * Set the Runtime instance
71
     *
72
     * @param Runtime $runtime
73
     * @return AbstractTask
74
     */
75 72
    public function setRuntime(Runtime $runtime)
76
    {
77 72
        $this->runtime = $runtime;
78 72
        return $this;
79
    }
80
81
    /**
82
     * Return Default options
83
     * @return array
84
     */
85 43
    public function getDefaults()
86
    {
87 43
        return [];
88
    }
89
}
90