summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Capabilities.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Data/Capabilities.php')
-rw-r--r--matrix-specification/Data/Capabilities.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/matrix-specification/Data/Capabilities.php b/matrix-specification/Data/Capabilities.php
new file mode 100644
index 0000000..3aa54a7
--- /dev/null
+++ b/matrix-specification/Data/Capabilities.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Matrix\Data;
+
+use Matrix\Data\Capability\BooleanCapability;
+use Matrix\Data\Capability\ProfileFieldsCapability;
+use Matrix\Data\Capability\RoomVersionsCapability;
+
+class Capabilities implements \JsonSerializable
+{
+ /**
+ * @param array<string, mixed> $otherProperties
+ */
+ public function __construct(
+ private ?BooleanCapability $threePidChanges = null,
+ private ?BooleanCapability $changePassword = null,
+ private ?BooleanCapability $getLoginToken = null,
+ private ?ProfileFieldsCapability $profileFields = null,
+ private ?RoomVersionsCapability $roomVersions = null,
+ private ?BooleanCapability $setAvatarUrl = null,
+ private ?BooleanCapability $setDisplayname = null,
+ private ?array $otherProperties = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ $data = [
+ "m.3pid_changes" => $this->threePidChanges,
+ "m.change_password" => $this->changePassword,
+ "m.get_login_token" => $this->getLoginToken,
+ "m.profile_fields" => $this->profileFields,
+ "m.room_versions" => $this->roomVersions,
+ "m.set_avatar_url" => $this->setAvatarUrl,
+ "m.set_displayname" => $this->setDisplayname,
+ ];
+
+ if (! empty($this->otherProperties)) {
+ $data += $this->otherProperties;
+ }
+
+ return array_filter($data, fn ($value) => ! is_null($value));
+ }
+}