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

InterruptNodeAbstract   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 57
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A exec() 0 21 4
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
use fab2s\NodalFlow\NodalFlowException;
14
15
/**
16
 * Abstract Class InterruptNodeAbstract
17
 */
18
abstract class InterruptNodeAbstract extends NodeAbstract implements InterruptNodeInterface
19
{
20
    /**
21
     * Indicate if this Node is traversable
22
     *
23
     * @var bool
24
     */
25
    protected $isATraversable = false;
26
27
    /**
28
     * Indicate if this Node is returning a value
29
     *
30
     * @var bool
31
     */
32
    protected $isAReturningVal = false;
33
34
    /**
35
     * Indicate if this Node is a Flow (Branch)
36
     *
37
     * @var bool
38
     */
39
    protected $isAFlow = false;
40
41
    /**
42
     * The CallableInterruptNode's payload interface is simple :
43
     *      - return false to break
44
     *      - return true to continue
45
     *      - return void|null (whatever) to proceed with the flow
46
     *
47
     * @param mixed $param
48
     *
49
     * @throws NodalFlowException
50
     *
51
     * @return mixed|void
52
     */
53
    public function exec($param)
54
    {
55
        $flowInterrupt = $this->interrupt($param);
56
        if ($flowInterrupt === null) {
57
            // do nothing, let the flow proceed
58
            return;
59
        }
60
61
        $flowInterruptType = null;
0 ignored issues
show
Unused Code introduced by
$flowInterruptType is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
62
        if ($flowInterrupt instanceof  InterrupterInterface) {
63
            $flowInterruptType = $flowInterrupt->getType();
64
        } elseif ($flowInterrupt) {
65
            $flowInterruptType = InterrupterInterface::TYPE_CONTINUE;
66
            $flowInterrupt     = null;
67
        } else {
68
            $flowInterruptType = InterrupterInterface::TYPE_BREAK;
69
            $flowInterrupt     = null;
70
        }
71
72
        $this->carrier->interruptFlow($flowInterruptType, $flowInterrupt);
73
    }
74
}
75