Executable::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-07-05 
5
 */
6
7
namespace Net\Bazzline\Component\Cli\Readline\Configuration;
8
9
use Closure;
10
use Net\Bazzline\Component\GenericAgreement\Exception\ExceptionInterface;
11
use Net\Bazzline\Component\GenericAgreement\Process\ExecutableInterface;
12
13
class Executable implements ExecutableInterface
14
{
15
    /** @var string|array|Closure */
16
    private $executable;
17
18
    /**
19
     * @param string|array $arrayOrString
20
     * @return $this
21
     */
22
    public function setExecutable($arrayOrString)
23
    {
24
        $this->executable = $arrayOrString;
25
26
        return $this;
27
    }
28
29
    /**
30
     * @param mixed $data
31
     * @return mixed
32
     * @throws ExceptionInterface
33
     */
34
    public function execute($data)
35
    {
36
        $executable = $this->executable;
37
38
        if (is_null($data)) {
39
            call_user_func($executable);
40
        } else {
41
            call_user_func_array($executable, $data);
42
        }
43
    }
44
}