blob: 600c618f1bace456d770cc9d75956315baa7a4ef (
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
|
<?php
namespace Matrix\Data\Room;
class AllowCondition implements \JsonSerializable
{
public function __construct(
private string $type,
private ?string $roomId = null,
)
{
if ($type == "m.room.membership" && empty($roomId)) {
throw new \InvalidArgumentException("room id is required");
}
}
public function jsonSerialize(): array
{
return array_filter([
"room_id" => $this->roomId,
"type" => $this->type,
], fn ($value) => ! is_null($value));
}
}
|