Passed
Pull Request — master (#1)
by Fabrice
03:00
created

CallableQualifier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of YaEtl.
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
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\YaEtl\Qualifiers;
11
12
use fab2s\NodalFlow\Flows\InterrupterInterface;
13
use fab2s\NodalFlow\NodalFlowException;
14
15
/**
16
 * Class CallableQualifier
17
 */
18
class CallableQualifier extends QualifierAbstract
19
{
20
    /**
21
     * @var callable
22
     */
23
    protected $qualifier;
24
25
    /**
26
     * Instantiate a CallableQualifier Node
27
     *
28
     * @param callable $qualifier
29
     *
30
     * @throws NodalFlowException
31
     */
32
    public function __construct(callable $qualifier)
33
    {
34
        $this->qualifier = $qualifier;
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 qualify($param)
47
    {
48
        return \call_user_func($this->qualifier, $param);
49
    }
50
}
51