@@ -10,8 +10,8 @@ final class Event
1010 /** @var string|null */
1111 private $ event ;
1212
13- /** @var array< string> */
14- private $ comments = [] ;
13+ /** @var string */
14+ private $ comment = '' ;
1515
1616 /** @var string */
1717 private $ data = '' ;
@@ -28,23 +28,23 @@ public function __construct(?string $event = null)
2828 }
2929
3030 /**
31- * Append one or more comments .
31+ * Set the event comment, supports line breaks .
3232 * Do not prefix comments with a colon – this is done by the encoder.
3333 *
34- * @param string ...$comments
34+ * @param string $comment
3535 * @return self
3636 */
37- public function comment (string ... $ comments ): self
37+ public function comment (string $ comment ): self
3838 {
3939 $ clone = clone $ this ;
4040
41- array_push ( $ clone ->comments , ... $ comments ) ;
41+ $ clone ->comment = $ comment ;
4242
4343 return $ clone ;
4444 }
4545
4646 /**
47- * Set the event data.
47+ * Set the event data, supports line breaks .
4848 *
4949 * @param string $data
5050 * @return $this
@@ -96,7 +96,7 @@ public function retry(?int $retry): self
9696 public function toString (Encoder $ encoder ): string
9797 {
9898 return $ encoder (
99- $ this ->comments ,
99+ $ this ->comment ,
100100 $ this ->event ,
101101 $ this ->data ,
102102 $ this ->id ,
@@ -105,16 +105,16 @@ public function toString(Encoder $encoder): string
105105 }
106106
107107 /**
108- * Determine if this event consists only of comments .
108+ * Determine if this event consists only of a comment .
109109 *
110110 * @return bool
111111 */
112- public function consistsOnlyOfComments (): bool
112+ public function consistsOnlyOfComment (): bool
113113 {
114114 return is_null ($ this ->event )
115115 && is_null ($ this ->retry )
116116 && $ this ->data === ''
117- && $ this ->comments !== [] ;
117+ && $ this ->comment !== '' ;
118118 }
119119}
120120
0 commit comments