summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/UserIdentifier.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
committerDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
commitb19a8f63ad727a3633885d3f2b81edf8181a53b9 (patch)
tree6b5fd70224a125a16010a291e5fd0df834e9436f /matrix-specification/Data/UserIdentifier.php
parentb08047ba485f86038f33175162943c0a9878ab1a (diff)
matrix-specification split work in progress
Diffstat (limited to 'matrix-specification/Data/UserIdentifier.php')
-rw-r--r--matrix-specification/Data/UserIdentifier.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/matrix-specification/Data/UserIdentifier.php b/matrix-specification/Data/UserIdentifier.php
new file mode 100644
index 0000000..8fcdae0
--- /dev/null
+++ b/matrix-specification/Data/UserIdentifier.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Matrix\Data;
+
+use Matrix\Enums\UserIdentifierType;
+
+class UserIdentifier implements \JsonSerializable
+{
+ public function __construct(
+ private UserIdentifierType $type,
+ private ?string $user = null,
+ private ?string $thirdPartyMedium = null,
+ private ?string $thirdPartyAddress = null,
+ private ?string $phoneCountry = null,
+ private ?string $phoneNumber = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ $userIdentifier = [
+ "type" => $this->type,
+ ];
+
+ $userIdentifier += match ($this->type) {
+ UserIdentifierType::USER => [
+ "user" => $this->user,
+ ],
+
+ UserIdentifierType::THIRDPARTY => [
+ "medium" => $this->thirdPartyMedium,
+ "address" => $this->thirdPartyAddress,
+ ],
+
+ UserIdentifierType::PHONE => [
+ "country" => $this->phoneCountry,
+ "phone" => $this->phoneNumber,
+ ],
+
+ default => [],
+ };
+
+ return $userIdentifier;
+ }
+}