Total Complexity | 4 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | class CallableNode extends PayloadNodeAbstract implements TraversableNodeInterface, ExecNodeInterface |
||
19 | { |
||
20 | /** |
||
21 | * The underlying executable or traversable Payload |
||
22 | * |
||
23 | * @var callable |
||
24 | */ |
||
25 | protected $payload; |
||
26 | |||
27 | /** |
||
28 | * Instantiate a Callable Node |
||
29 | * |
||
30 | * @param callable $payload |
||
31 | * @param bool $isAReturningVal |
||
32 | * @param bool $isATraversable |
||
33 | * |
||
34 | * @throws NodalFlowException |
||
35 | */ |
||
36 | public function __construct(callable $payload, bool $isAReturningVal, bool $isATraversable = false) |
||
37 | { |
||
38 | parent::__construct($payload, $isAReturningVal, $isATraversable); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Execute this node |
||
43 | * |
||
44 | * @param mixed|null $param |
||
45 | * |
||
46 | * @return mixed |
||
47 | */ |
||
48 | public function exec($param = null) |
||
49 | { |
||
50 | return \call_user_func($this->payload, $param); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get this Node's Traversable |
||
55 | * |
||
56 | * @param mixed $param |
||
57 | * |
||
58 | * @return Generator |
||
59 | */ |
||
60 | public function getTraversable($param = null): iterable |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 |