summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php')
-rw-r--r--matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
new file mode 100644
index 0000000..f38e2b0
--- /dev/null
+++ b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Matrix\Responses;
+
+use Matrix\Data\Contact;
+
+class WellKnownMatrixSupportGetResponse implements \JsonSerializable
+{
+ /**
+ * @param Contact[] $contacts
+ */
+ public function __construct(
+ private ?array $contacts = null,
+ private ?string $supportPage = null,
+ )
+ {
+ if (is_null($contacts) && is_null($supportPage)) {
+ throw new \InvalidArgumentException("at least one of contacts or supportPage is required");
+ }
+
+ if (! is_null($contacts) && is_null($supportPage) && empty($contacts)) {
+ throw new \InvalidArgumentException("if only contacts is set, it must contain at least one item");
+ }
+ }
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "contacts" => $this->contacts,
+ "support_page" => $this->supportPage,
+ ], "is_null");
+ }
+}