Completed
Push — master ( 5635b0...3b50b8 )
by Christian
02:38
created

ExecuteCode::getName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
crap 6
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
     * @param $description string Description of what this code does.
22
     * @param $callback callable The callback to execute. The callback will receive $config, $input and $output as parameters.
23
     */
24 1
    public function __construct($description, $callback)
25
    {
26 1
        $this->description = $description;
27 1
        $this->callback = $callback;
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getName()
34
    {
35
        return ($this->description ?: 'Execute Custom Code') . ' (ExecuteCode)';
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function checkSupport()
42
    {
43
        // no special dependencies
44
    }
45
46
    /**
47
     * Execute action for the given parameters.
48
     *
49
     * @param InputInterface $input
50
     * @param OutputInterface $output
51
     */
52 1
    public function execute(InputInterface $input, OutputInterface $output)
53
    {
54 1
        call_user_func($this->callback, $this->config, $input, $output);
55
    }
56
}