Passed
Pull Request — master (#2)
by Pol
03:05
created

BaseTask::getTaskArguments()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 4
nop 0
dl 0
loc 23
ccs 0
cts 18
cp 0
crap 20
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace PhpTaskman\Core\Plugin;
6
7
use PhpTaskman\Core\Contract\TaskInterface;
8
use Robo\Contract\BuilderAwareInterface;
9
use Robo\TaskAccessor;
10
11
abstract class BaseTask extends \Robo\Task\BaseTask implements TaskInterface, BuilderAwareInterface
12
{
13
    use TaskAccessor;
14
15
    public const ARGUMENTS = [];
16
    public const NAME = 'NULL';
17
18
    /**
19
     * @var array
20
     */
21
    private $options;
22
23
    /**
24
     * @var array
25
     */
26
    private $task;
27
28
    /**
29
     * @return array
30
     */
31
    public function getOptions()
32
    {
33
        return $this->options;
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getTask()
40
    {
41
        return $this->task;
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function getTaskArguments()
48
    {
49
        $task = $this->getTask();
50
        unset($task['task']);
51
52
        $arguments = \array_combine(
53
            static::ARGUMENTS,
54
            static::ARGUMENTS
55
        );
56
57
        if (empty($arguments)) {
58
            return $task;
59
        }
60
61
        foreach ($task as $key => $value) {
62
            if (isset($arguments[$key])) {
63
                continue;
64
            }
65
66
            unset($task[$key]);
67
        }
68
69
        return $task;
70
    }
71
72
    /**
73
     * @param array $options
74
     */
75
    public function setOptions(array $options = [])
76
    {
77
        $this->options = $options;
78
    }
79
80
    /**
81
     * @param array $task
82
     */
83
    public function setTask(array $task = [])
84
    {
85
        $this->task = $task;
86
    }
87
}
88