Total Complexity | 3 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | abstract class Parser |
||
8 | { |
||
9 | /** |
||
10 | * Strategy classes need to implement handle method. |
||
11 | */ |
||
12 | protected $strategies = []; |
||
13 | |||
14 | /** |
||
15 | * Execute strategies before decoding payload. |
||
16 | * If return value is true will skip decoding. |
||
17 | * |
||
18 | * @param \Swoole\WebSocket\Server $server |
||
19 | * @param \Swoole\WebSocket\Frame $frame |
||
20 | * |
||
21 | * @return boolean |
||
22 | */ |
||
23 | public function execute($server, $frame) |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Encode output payload for websocket push. |
||
46 | * |
||
47 | * @param string $event |
||
48 | * @param mixed $data |
||
49 | * |
||
50 | * @return mixed |
||
51 | */ |
||
52 | abstract public function encode(string $event, $data); |
||
53 | |||
54 | /** |
||
55 | * Input message on websocket connected. |
||
56 | * Define and return event name and payload data here. |
||
57 | * |
||
58 | * @param \Swoole\Websocket\Frame $frame |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | abstract public function decode($frame); |
||
63 | } |
||
64 |