summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/StateEvent.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Events/StateEvent.php')
-rw-r--r--matrix-specification/Events/StateEvent.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/matrix-specification/Events/StateEvent.php b/matrix-specification/Events/StateEvent.php
new file mode 100644
index 0000000..7fe7c83
--- /dev/null
+++ b/matrix-specification/Events/StateEvent.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Matrix\Events;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+
+class StateEvent extends ClientEvent
+{
+ public function __construct(
+ array $content,
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ protected string $stateKey,
+ EventType $type,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ $content,
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ $type,
+ $unsigned,
+ );
+ }
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "content" => $this->content ?: new \stdClass,
+ "event_id" => $this->eventId,
+ "origin_server_ts" => $this->originServerTimestamp,
+ "room_id" => $this->roomId,
+ "sender" => $this->sender,
+ "state_key" => $this->stateKey,
+ "type" => $this->type,
+ "unsigned" => $this->unsigned ?? new \stdClass,
+ ];
+ }
+
+ public function getStateKey(): string
+ {
+ return $this->stateKey;
+ }
+}