summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/UnsignedData.php
blob: 924af29adb6c363c402bf503550353b1872fc9b3 (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
<?php

namespace Matrix\Events;

use Matrix\Enums\MembershipState;

/**
 * @see https://spec.matrix.org/v1.16/client-server-api/#definition-clientevent_unsigneddata
 */
class UnsignedData implements \JsonSerializable
{
  public function __construct(
    private ?int $age = null,
    private ?MembershipState $membership = null,
    private ?array $previousContent = null,
    private ?ClientEvent $redactedBecause = null,
    private ?string $transactionId = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "age" => $this->age,
      "membership" => $this->membership,
      "prev_content" => $this->previousContent,
      "redacted_because" => $this->redactedBecause,
      "transaction_id" => $this->transactionId,
    ], "is_null");
  }
}