summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room/RoomSummary.php
blob: 5ac86a8485cb20cea8a24736ace4cf6ea6f384f9 (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
<?php

namespace Matrix\Data\Room;

class RoomSummary implements \JsonSerializable
{
  /**
   * @param string[] $heroes
   */
  public function __construct(
    private ?array $heroes = null,
    private ?int $invitedMemberCount = null,
    private ?int $joinedMemberCount = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "m.heroes" => $this->heroes,
      "m.invited_member_count" => $this->invitedMemberCount,
      "m.joined_member_count" => $this->joinedMemberCount,
    ], fn ($value) => ! is_null($value));
  }
}