summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/DiscoveryInformation.php
blob: f4eda6482caabbc8058a4de42aaf755d6b064edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Matrix\Data;

class DiscoveryInformation implements \JsonSerializable
{
  /**
   * @param array<string, array<mixed, mixed>> $otherProperties
   */
  public function __construct(
    private HomeServerInformation $homeServerInformation,
    private IdentityServerInformation $identityServerInformation,
    private ?array $otherProperties = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter(
      array_merge(
        [
          "m.homeserver" => $this->homeServerInformation,
          "m.identity_server" => $this->identityServerInformation,
        ],
        $this->otherProperties ?? [],
      ),
      fn ($value) => ! is_null($value)
    );
  }
}