1 | <?php |
||
15 | class StreamEvent |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * Strng pattern END_OF_LINE |
||
20 | * |
||
21 | * @var string END_OF_LINE |
||
22 | */ |
||
23 | const END_OF_LINE = "/\r\n|\n|\r/"; |
||
24 | |||
25 | /** |
||
26 | * Raw data form stream |
||
27 | * |
||
28 | * @var string $data |
||
29 | */ |
||
30 | private $data; |
||
31 | |||
32 | /** |
||
33 | * Type of event |
||
34 | * |
||
35 | * @var string $eventType |
||
36 | */ |
||
37 | private $eventType; |
||
38 | |||
39 | /** |
||
40 | * |
||
41 | * @param string $data |
||
42 | * @param string $eventType |
||
43 | */ |
||
44 | public function __construct(string $data = '', string $eventType = 'message') |
||
49 | |||
50 | /** |
||
51 | * |
||
52 | * @param $raw |
||
53 | * @return StreamEvent $event |
||
54 | */ |
||
55 | public static function parse($raw) |
||
82 | |||
83 | /** |
||
84 | * Return Object |
||
85 | * |
||
86 | * @param \ZendFirebase\Stream\StreamEvent $event |
||
87 | * @param string $name |
||
88 | * @param string $value |
||
89 | * @return \ZendFirebase\Stream\StreamEvent |
||
90 | */ |
||
91 | private static function parseEventData(StreamEvent $event, string $name, string $value): StreamEvent |
||
109 | |||
110 | |||
111 | /** |
||
112 | * Find enf of stream |
||
113 | * |
||
114 | * @param mixed $raw |
||
115 | * @return array |
||
116 | */ |
||
117 | private static function splitEndOfStream($raw):array |
||
122 | |||
123 | |||
124 | /** |
||
125 | * All db changes |
||
126 | * |
||
127 | * @return string $this->data |
||
128 | */ |
||
129 | public function getData(): string |
||
133 | |||
134 | /** |
||
135 | * Type of event |
||
136 | * |
||
137 | * @return string $this->eventType |
||
138 | */ |
||
139 | public function getEventType(): string |
||
143 | } |
||
144 |