Passed
Push — master ( 97b1e7...36e7dc )
by Fabrice
02:16
created

FlowEventProxyTrait::setNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
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\Events;
11
12
use fab2s\NodalFlow\Flows\FlowInterface;
13
use fab2s\NodalFlow\Nodes\NodeInterface;
14
15
/**
16
 * trait FlowEventProxyTrait
17
 *
18
 * A good example on how BC could use the S from Symfony
19
 */
20
trait FlowEventProxyTrait
21
{
22
    /**
23
     * @var array
24
     */
25
    protected static $eventList;
26
27
    /**
28
     * @var FlowInterface
29
     */
30
    protected $flow;
31
32
    /**
33
     * @var NodeInterface|null
34
     */
35
    protected $node;
36
37
    /**
38
     * FlowEvent constructor.
39
     *
40
     * @param FlowInterface      $flow
41
     * @param NodeInterface|null $node
42
     */
43
    public function __construct(FlowInterface $flow, NodeInterface $node = null)
44
    {
45
        $this->flow = $flow;
46
        $this->node = $node;
47
    }
48
49
    /**
50
     * @return FlowInterface
51
     */
52
    public function getFlow(): FlowInterface
53
    {
54
        return $this->flow;
55
    }
56
57
    /**
58
     * @return NodeInterface|null
59
     */
60
    public function getNode(): ? NodeInterface
61
    {
62
        return $this->node;
63
    }
64
65
    /**
66
     * @param NodeInterface|null $node
67
     *
68
     * @return FlowEventInterface
69
     */
70
    public function setNode(NodeInterface $node = null): FlowEventInterface
71
    {
72
        $this->node = $node;
73
74
        /* @var FlowEventInterface $this */
75
        return $this;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public static function getEventList(): array
82
    {
83
        /* @var FlowEventInterface $this */
84
        if (!isset(static::$eventList)) {
0 ignored issues
show
Bug introduced by
Accessing eventList on the interface fab2s\NodalFlow\Events\FlowEventInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
85
            static::$eventList = [
86
                static::FLOW_START    => static::FLOW_START,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...tProxyTrait::FLOW_START was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
87
                static::FLOW_PROGRESS => static::FLOW_PROGRESS,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...oxyTrait::FLOW_PROGRESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88
                static::FLOW_CONTINUE => static::FLOW_CONTINUE,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...oxyTrait::FLOW_CONTINUE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
89
                static::FLOW_BREAK    => static::FLOW_BREAK,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...tProxyTrait::FLOW_BREAK was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90
                static::FLOW_SUCCESS  => static::FLOW_SUCCESS,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...roxyTrait::FLOW_SUCCESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
91
                static::FLOW_FAIL     => static::FLOW_FAIL,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...ntProxyTrait::FLOW_FAIL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
92
            ];
93
        }
94
95
        return static::$eventList;
96
    }
97
}
98