CallbackAction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Thruster\Component\Actions\Action;
4
5
use Thruster\Component\Actions\ExecutorInterface;
6
use Thruster\Component\Actions\ExecutorLessInterface;
7
8
/**
9
 * Class CallbackAction
10
 *
11
 * @package Thruster\Component\Actions\Action
12
 * @author  Aurimas Niekis <[email protected]>
13
 */
14
class CallbackAction extends BaseAction implements ExecutorLessInterface
15
{
16
    /**
17
     * @var callable
18
     */
19
    protected $callback;
20
21
    /**
22
     * @param callable $callback
23
     */
24 5
    public function __construct(callable $callback)
25
    {
26 5
        $this->callback = $callback;
27 5
        $this->arguments = array_slice(func_get_args(), 1);
28 5
    }
29
30
    /**
31
     * @param ExecutorInterface $executor
32
     *
33
     * @return mixed
34
     */
35 4
    public function parseArguments(ExecutorInterface $executor)
36
    {
37 4
        return call_user_func_array($this->callback, parent::parseArguments($executor));
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43 1
    public function getName() : string
44
    {
45 1
        return 'thruster_callback';
46
    }
47
48
}
49