1 | <?php |
||
19 | abstract class AbstractNetworkDecorator implements NetworkInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var NetworkInterface |
||
23 | */ |
||
24 | protected $network; |
||
25 | |||
26 | /** |
||
27 | * AbstractNetworkAdapter constructor. |
||
28 | * |
||
29 | * @param NetworkInterface $network |
||
30 | */ |
||
31 | 2 | public function __construct(NetworkInterface $network) |
|
35 | |||
36 | /** |
||
37 | * @return NetworkInterface |
||
38 | */ |
||
39 | 2 | public function getNetwork() : NetworkInterface |
|
43 | |||
44 | /** |
||
45 | * @return null|Graph |
||
46 | */ |
||
47 | 1 | public function getGraph() |
|
51 | |||
52 | /** |
||
53 | * Cleanup network state after runs. |
||
54 | * |
||
55 | * @return NetworkDecoratorInterface |
||
56 | */ |
||
57 | 1 | public function shutdown() |
|
63 | |||
64 | /** |
||
65 | * @param mixed $data |
||
66 | * @param string $node |
||
67 | * @param string $port |
||
68 | * @return $this |
||
69 | * @throws InvalidDefinitionException |
||
70 | */ |
||
71 | public function addInitial($data, string $node, string $port) |
||
77 | |||
78 | /** |
||
79 | * Add a closure to an event |
||
80 | * |
||
81 | * Accepted events are connect, disconnect and data |
||
82 | * Closures will be given the |
||
83 | * |
||
84 | * @param string $alias |
||
85 | * @param string $event |
||
86 | * @param \Closure $closure |
||
87 | * @throws FlowException |
||
88 | * @throws InvalidTypeException |
||
89 | * @return $this |
||
90 | */ |
||
91 | 1 | public function hook(string $alias, string $event, \Closure $closure) |
|
97 | |||
98 | /** |
||
99 | * Get all defined custom event hooks |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | 1 | public function hooks() : array |
|
107 | |||
108 | /** |
||
109 | * @return bool|\DateInterval |
||
110 | */ |
||
111 | 1 | public function uptime() |
|
115 | |||
116 | /** |
||
117 | * @param array $node |
||
118 | * @return $this |
||
119 | * @throws \PhpFlo\Common\InvalidDefinitionException |
||
120 | */ |
||
121 | 1 | public function addNode(array $node) |
|
127 | |||
128 | /** |
||
129 | * @param array $node |
||
130 | * @return NetworkInterface |
||
131 | */ |
||
132 | 1 | public function removeNode(array $node) : NetworkInterface |
|
138 | |||
139 | /** |
||
140 | * @param string $id |
||
141 | * @return mixed|null |
||
142 | */ |
||
143 | 1 | public function getNode(string $id) |
|
147 | |||
148 | /** |
||
149 | * @param array $edge |
||
150 | * @return NetworkInterface |
||
151 | * @throws \PhpFlo\Common\InvalidDefinitionException |
||
152 | */ |
||
153 | 1 | public function addEdge(array $edge) : NetworkInterface |
|
159 | |||
160 | /** |
||
161 | * @param array $edge |
||
162 | * @return NetworkInterface |
||
163 | */ |
||
164 | 1 | public function removeEdge(array $edge) : NetworkInterface |
|
170 | |||
171 | /** |
||
172 | * Add a flow definition as Graph object or definition file/string |
||
173 | * and initialize the network processes/connections |
||
174 | * |
||
175 | * @param mixed $graph |
||
176 | * @return NetworkInterface |
||
177 | * @throws \PhpFlo\Common\InvalidDefinitionException |
||
178 | */ |
||
179 | 1 | public function boot($graph) : NetworkInterface |
|
185 | |||
186 | /** |
||
187 | * @param mixed $data |
||
188 | * @param string $node |
||
189 | * @param string $port |
||
190 | * @return NetworkInterface |
||
191 | */ |
||
192 | 1 | public function run($data, string $node, string $port) : NetworkInterface |
|
198 | } |
||
199 |