CallableInterruptNode::interrupt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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\Flows\InterrupterInterface;
13
use fab2s\NodalFlow\NodalFlowException;
14
15
/**
16
 * Class CallableInterruptNode
17
 */
18
class CallableInterruptNode extends InterruptNodeAbstract
19
{
20
    /**
21
     * @var callable
22
     */
23
    protected $interrupter;
24
25
    /**
26
     * Instantiate a CallableInterruptNode Node
27
     *
28
     * @param callable $interrupter
29
     *
30
     * @throws NodalFlowException
31
     */
32
    public function __construct(callable $interrupter)
33
    {
34
        $this->interrupter = $interrupter;
35
        parent::__construct();
36
    }
37
38
    /**
39
     * @param mixed $param
40
     *
41
     * @return InterrupterInterface|null|bool `null` do do nothing, eg let the Flow proceed untouched
42
     *                                        `true` to trigger a continue on the carrier Flow (not ancestors)
43
     *                                        `false` to trigger a break on the carrier Flow (not ancestors)
44
     *                                        `InterrupterInterface` to trigger an interrupt to propagate up to a target (which may be one ancestor)
45
     */
46
    public function interrupt($param)
47
    {
48
        return \call_user_func($this->interrupter, $param);
49
    }
50
}
51