summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room/TextualRepresentation.php
blob: 9b66f48b2e4770f6ad65b93d5969028792fcf4e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

namespace Matrix\Data\Room;

class TextualRepresentation implements \JsonSerializable
{
  public function __construct(
    private string $body,
    private ?string $mimeType = "text/plain",
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "body" => $this->body,
      "mimetype" => $this->mimeType,
    ], fn ($value) => ! is_null($value));
  }
}