Completed
Push — master ( ddc20e...61f12d )
by Fabrice
03:08
created

CallableInterruptNode::interrupt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of NodalFlow.
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/NodalFlow
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\NodalFlow\Nodes;
11
12
use fab2s\NodalFlow\InterrupterInterface;
13
14
/**
15
 * Class CallableInterruptNode
16
 */
17
class CallableInterruptNode extends InterruptNodeAbstract
18
{
19
    /**
20
     * @var callable
21
     */
22
    protected $interrupter;
23
24
    /**
25
     * Instantiate a CallableInterruptNode Node
26
     *
27
     * @param callable $interrupter
28
     */
29
    public function __construct(callable $interrupter)
30
    {
31
        $this->interrupter = $interrupter;
32
        parent::__construct();
33
    }
34
35
    /**
36
     * @param mixed $param
37
     *
38
     * @return InterrupterInterface|null|bool `null` do do nothing, eg let the Flow proceed untouched
39
     *                                        `true` to trigger a continue on the carrier Flow (not ancestors)
40
     *                                        `false` to trigger a break on the carrier Flow (not ancestors)
41
     *                                        `InterrupterInterface` to trigger an interrupt to propagate up to a target (which may be one ancestor)
42
     */
43
    public function interrupt($param)
44
    {
45
        return \call_user_func($this->interrupter, $param);
46
    }
47
}
48