summaryrefslogtreecommitdiff
path: root/matrix-specification/Data
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2026-04-14 16:33:04 +0200
committerDaniel Weipert <git@mail.dweipert.de>2026-04-14 16:33:04 +0200
commitf3202403339e94f0186b9ff19e83c7a32fdad198 (patch)
treec3310b1f456f12a7a92f51948d9c8caf94f11032 /matrix-specification/Data
parent875b9ece501de5937993c41a83c44f8ea59897d0 (diff)
implementing against Cinny and iamb some moreHEADmain
Diffstat (limited to 'matrix-specification/Data')
-rw-r--r--matrix-specification/Data/Capabilities.php44
-rw-r--r--matrix-specification/Data/Capability/BooleanCapability.php18
-rw-r--r--matrix-specification/Data/Capability/ProfileFieldsCapability.php26
-rw-r--r--matrix-specification/Data/Capability/RoomVersionsCapability.php23
4 files changed, 111 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));
+ }
+}
diff --git a/matrix-specification/Data/Capability/BooleanCapability.php b/matrix-specification/Data/Capability/BooleanCapability.php
new file mode 100644
index 0000000..13cb4de
--- /dev/null
+++ b/matrix-specification/Data/Capability/BooleanCapability.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Matrix\Data\Capability;
+
+class BooleanCapability implements \JsonSerializable
+{
+ public function __construct(
+ private bool $enabled,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "enabled" => $this->enabled,
+ ];
+ }
+}
diff --git a/matrix-specification/Data/Capability/ProfileFieldsCapability.php b/matrix-specification/Data/Capability/ProfileFieldsCapability.php
new file mode 100644
index 0000000..91b0fc4
--- /dev/null
+++ b/matrix-specification/Data/Capability/ProfileFieldsCapability.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Matrix\Data\Capability;
+
+class ProfileFieldsCapability implements \JsonSerializable
+{
+ /**
+ * @param string[] $allowed
+ * @param string[] $disallowed
+ */
+ public function __construct(
+ private bool $enabled,
+ private ?array $allowed = null,
+ private ?array $disallowed = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "allowed" => $this->allowed,
+ "disallowed" => $this->disallowed,
+ "enabled" => $this->enabled,
+ ], fn ($value) => ! is_null($value));
+ }
+}
diff --git a/matrix-specification/Data/Capability/RoomVersionsCapability.php b/matrix-specification/Data/Capability/RoomVersionsCapability.php
new file mode 100644
index 0000000..d2a5cd7
--- /dev/null
+++ b/matrix-specification/Data/Capability/RoomVersionsCapability.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Matrix\Data\Capability;
+
+class RoomVersionsCapability implements \JsonSerializable
+{
+ /**
+ * @param array<string, string> $available
+ */
+ public function __construct(
+ private array $available,
+ private string $default,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "available" => $this->available,
+ "default" => $this->default,
+ ];
+ }
+}