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

namespace Matrix\Data\Room;

use Matrix\Events\ClientEventWithoutRoomId;

class Timeline implements \JsonSerializable
{
  /**
   * @param ClientEventWithoutRoomId[] $events
   */
  public function __construct(
    private array $events,
    private ?bool $limited = null,
    private ?string $previousBatch = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "events" => $this->events,
      "limited" => $this->limited,
      "prev_batch" => $this->previousBatch,
    ], "is_null");
  }
}