Completed
Pull Request — master (#2)
by Pol
05:26 queued 01:00
created

BaseTask   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 47
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTaskArguments() 0 24 4
A setTaskArguments() 0 3 1
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
     * @return array
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
     * @param array $arguments
54
     */
55
    public function setTaskArguments(array $arguments = [])
56
    {
57
        $this->arguments = $arguments;
58
    }
59
}
60