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

AbstractTask::getDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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