Passed
Pull Request — master (#2)
by Pol
02:23
created

BaseTask::setTaskArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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 $arguments;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getTaskArguments()
27
    {
28
        $arguments = $this->arguments;
29
30
        unset($arguments['task']);
31
32
        $argumentsAllowed = \array_combine(
33
            static::ARGUMENTS,
34
            static::ARGUMENTS
35
        );
36
37
        if (empty($argumentsAllowed)) {
38
            return $arguments;
39
        }
40
41
        foreach ($arguments as $key => $value) {
42
            if (isset($argumentsAllowed[$key])) {
43
                continue;
44
            }
45
46
            unset($arguments[$key]);
47
        }
48
49
        return $arguments;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function setTaskArguments(array $arguments = [])
56
    {
57
        $this->arguments = $arguments;
58
59
        return $this;
60
    }
61
}
62