summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room/Timeline.php
blob: 8d70dddba7f2842c27762d4f01b9c261c50fc98b (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,
    ], fn ($value) => ! is_null($value));
  }
}