Passed
Push — master ( ad4b35...1f9feb )
by Fabrice
02:24
created

FlowEventProxy::getEventList()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 9.9666
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 FlowEventProxy
17
 *
18
 * A good example on how BC could use the S from Symfony
19
 */
20
trait FlowEventProxy
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 $this
69
     */
70
    public function setNode(NodeInterface $node = null): FlowEventInterface
71
    {
72
        $this->node = $node;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return array
79
     */
80
    public static function getEventList(): array
81
    {
82
        if (!isset(static::$eventList)) {
83
            static::$eventList = [
84
                static::FLOW_START    => static::FLOW_START,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\FlowEventProxy::FLOW_START was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
85
                static::FLOW_PROGRESS => static::FLOW_PROGRESS,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...entProxy::FLOW_PROGRESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
86
                static::FLOW_CONTINUE => static::FLOW_CONTINUE,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...entProxy::FLOW_CONTINUE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
87
                static::FLOW_BREAK    => static::FLOW_BREAK,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\FlowEventProxy::FLOW_BREAK was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88
                static::FLOW_SUCCESS  => static::FLOW_SUCCESS,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\F...ventProxy::FLOW_SUCCESS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
89
                static::FLOW_FAIL     => static::FLOW_FAIL,
0 ignored issues
show
Bug introduced by
The constant fab2s\NodalFlow\Events\FlowEventProxy::FLOW_FAIL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90
            ];
91
        }
92
93
        return static::$eventList;
94
    }
95
}
96
97
if (class_exists('Symfony\Component\EventDispatcher\Event')) {
98
    class FlowEvent extends \Symfony\Component\EventDispatcher\Event implements FlowEventInterface
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\EventDispatcher\Event has been deprecated: since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

98
    class FlowEvent extends /** @scrutinizer ignore-deprecated */ \Symfony\Component\EventDispatcher\Event implements FlowEventInterface
Loading history...
99
    {
100
        use FlowEventProxy;
101
    }
102
} else {
103
    class FlowEvent extends \Symfony\Contracts\EventDispatcher\Event implements FlowEventInterface
104
    {
105
        use FlowEventProxy;
106
    }
107
}
108