BranchNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 2
dl 0
loc 4
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\FlowInterface;
13
use fab2s\NodalFlow\NodalFlowException;
14
15
/**
16
 * Class BranchNode
17
 */
18
class BranchNode extends PayloadNodeAbstract implements BranchNodeInterface
19
{
20
    /**
21
     * This Node is a Branch
22
     *
23
     * @var bool
24
     */
25
    protected $isAFlow = true;
26
27
    /**
28
     * @var FlowInterface
29
     */
30
    protected $payload;
31
32
    /**
33
     * Instantiate the BranchNode
34
     *
35
     * @param FlowInterface $payload
36
     * @param bool          $isAReturningVal
37
     *
38
     * @throws NodalFlowException
39
     */
40
    public function __construct(FlowInterface $payload, bool $isAReturningVal)
41
    {
42
        // branch Node does not (yet) support traversing
43
        parent::__construct($payload, $isAReturningVal, false);
44
    }
45
46
    /**
47
     * Execute the BranchNode
48
     *
49
     * @param mixed|null $param
50
     *
51
     * @return mixed
52
     */
53
    public function exec($param = null)
54
    {
55
        // in the branch case, we actually exec a Flow
56
        return $this->payload->exec($param);
57
    }
58
}
59