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

ExecuteCode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 2
cbo 1
dl 0
loc 48
ccs 10
cts 11
cp 0.9091
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A execute() 0 4 1
A getName() 0 4 2
A isSupported() 0 4 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