summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/ClientEventWithoutRoomId.php
blob: 0410d5be998064d5c7876be3f22831c67ea2a204 (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
<?php

namespace Matrix\Events;

use Matrix\Enums\EventType;

class ClientEventWithoutRoomId extends SenderEvent
{
  public function __construct(
    array $content,
    protected string $eventId,
    protected int $originServerTimestamp,
    string $sender,
    protected string $stateKey,
    EventType $type,
    protected ?UnsignedData $unsigned = null,
  )
  {
    parent::__construct($content, $sender, $type);
  }

  public function jsonSerialize(): array
  {
    return [
      "content" => $this->content ?: new \stdClass,
      "event_id" => $this->eventId,
      "origin_server_ts" => $this->originServerTimestamp,
      "sender" => $this->sender,
      "state_key" => $this->stateKey,
      "type" => $this->type,
      "unsigned" => $this->unsigned ?? new \stdClass,
    ];
  }
}