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

namespace Matrix\Data;

use Matrix\Enums\MembershipState;
use Matrix\Events\ClientEvent;

/**
 * @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,
    ], fn ($value) => ! is_null($value));
  }
}