summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room/AllowCondition.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Data/Room/AllowCondition.php')
-rw-r--r--matrix-specification/Data/Room/AllowCondition.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/matrix-specification/Data/Room/AllowCondition.php b/matrix-specification/Data/Room/AllowCondition.php
new file mode 100644
index 0000000..600c618
--- /dev/null
+++ b/matrix-specification/Data/Room/AllowCondition.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class AllowCondition implements \JsonSerializable
+{
+ public function __construct(
+ private string $type,
+ private ?string $roomId = null,
+ )
+ {
+ if ($type == "m.room.membership" && empty($roomId)) {
+ throw new \InvalidArgumentException("room id is required");
+ }
+ }
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "room_id" => $this->roomId,
+ "type" => $this->type,
+ ], fn ($value) => ! is_null($value));
+ }
+}