diff --git a/src/Igorw/EventSource/Event.php b/src/Igorw/EventSource/Event.php index 8da58e6..f538a83 100644 --- a/src/Igorw/EventSource/Event.php +++ b/src/Igorw/EventSource/Event.php @@ -19,6 +19,10 @@ class Event private $retry; private $data = array(); + /** + * @param $comment + * @return $this + */ public function addComment($comment) { $this->comments = array_merge( @@ -29,6 +33,10 @@ public function addComment($comment) return $this; } + /** + * @param $id + * @return $this + */ public function setId($id) { $this->id = $id; @@ -36,6 +44,10 @@ public function setId($id) return $this; } + /** + * @param $event + * @return $this + */ public function setEvent($event) { $this->event = $event; @@ -43,6 +55,10 @@ public function setEvent($event) return $this; } + /** + * @param $retry + * @return $this + */ public function setRetry($retry) { if (!is_numeric($retry)) { @@ -54,6 +70,10 @@ public function setRetry($retry) return $this; } + /** + * @param $data + * @return $this + */ public function setData($data) { $this->data = $this->extractNewlines($data); @@ -61,6 +81,10 @@ public function setData($data) return $this; } + /** + * @param $data + * @return $this + */ public function appendData($data) { $this->data = array_merge( @@ -71,6 +95,9 @@ public function appendData($data) return $this; } + /** + * @return string + */ public function dump() { $response = $this->getFormattedComments(). @@ -82,26 +109,41 @@ public function dump() return '' !== $response ? $response."\n" : ''; } + /** + * @return string + */ public function getFormattedComments() { return $this->formatLines('', $this->comments); } + /** + * @return string + */ public function getFormattedId() { return $this->formatLines('id', $this->id); } + /** + * @return string + */ public function getFormattedEvent() { return $this->formatLines('event', $this->event); } + /** + * @return string + */ public function getFormattedRetry() { return $this->formatLines('retry', $this->retry); } + /** + * @return string + */ public function getFormattedData() { return $this->formatLines('data', $this->data); @@ -124,6 +166,9 @@ function ($line) use ($key) { return implode('', $formatted); } + /** + * @return static + */ static public function create() { return new static(); diff --git a/src/Igorw/EventSource/EventWrapper.php b/src/Igorw/EventSource/EventWrapper.php index 36f34f5..b9cb5c2 100644 --- a/src/Igorw/EventSource/EventWrapper.php +++ b/src/Igorw/EventSource/EventWrapper.php @@ -22,11 +22,17 @@ public function __construct(Event $event, \Closure $source = null) $this->source = $source; } + /** + * @return Event + */ public function getWrappedEvent() { return $this->event; } + /** + * @return Stream + */ public function end() { if ($this->source) { diff --git a/src/Igorw/EventSource/Stream.php b/src/Igorw/EventSource/Stream.php index 212409f..77e2698 100644 --- a/src/Igorw/EventSource/Stream.php +++ b/src/Igorw/EventSource/Stream.php @@ -27,6 +27,9 @@ public function __construct($handler = null) $this->handler = $handler ?: new EchoHandler(); } + /** + * @return EventWrapper + */ public function event() { $event = new Event();