Completed
Push — master ( d372d6...3eec25 )
by Christian
02:37
created

ExecuteCode::isSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace uuf6429\ElderBrother\Action;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
class ExecuteCode extends ActionAbstract
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $description;
14
15
    /**
16
     * @var callable
17
     */
18
    protected $callback;
19
20
    /**
21
     * Executes the passed callback, function or static method.
22
     *
23
     * @param string   $description Description of the intention of the callback
24
     * @param callable $callback    The callback to execute. It will receive $config, $input and $output as parameters
25
     */
26 1
    public function __construct($description, $callback)
27
    {
28 1
        $this->description = $description;
29 1
        $this->callback = $callback;
30 1
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    public function getName()
36
    {
37 1
        return ($this->description ?: 'Execute Custom Code') . ' (ExecuteCode)';
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 1
    public function isSupported()
44
    {
45 1
        return true; // no special dependencies
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function execute(InputInterface $input, OutputInterface $output)
52
    {
53 1
        call_user_func($this->callback, $this->config, $input, $output);
54
    }
55
}
56