summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room/JoinedRoom.php
blob: 0057071136f5f0d2de9086e2b9ba4b6f9ad3d0e1 (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
31
32
33
34
35
36
37
<?php

namespace Matrix\Data\Room;

use Matrix\Data\AccountData;

class JoinedRoom implements \JsonSerializable
{
  /**
   * @param array<string, ThreadNotificationCounts>
   */
  public function __construct(
    private ?AccountData $accountData = null,
    private ?Ephemeral $ephemeral = null,
    private ?State $state = null,
    private ?State $stateAfter = null,
    private ?RoomSummary $summary = null,
    private ?Timeline $timeline = null,
    private ?UnreadNotificationCounts $unreadNotifications = null,
    private ?array $unreadThreadNotifications = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "account_data" => $this->inviteState,
      "ephemeral" => $this->ephemeral,
      "state" => $this->state,
      "state_after" => $this->stateAfter,
      "summary" => $this->summary,
      "timeline" => $this->timeline,
      "unread_notifications" => $this->unreadNotifications,
      "unreadThreadNotifications" => $this->unreadThreadNotifications,
    ], fn ($value) => ! is_null($value));
  }
}