blob: cd8fdf2e9175b539b8883f7861297f26b2bfa77f (
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
35
36
|
<?php
namespace Matrix\Data\Filters;
class EventFilter implements \JsonSerializable
{
/**
* @param string[] $notSenders
* @param string[] $notTypes
* @param string[] $senders
* @param string[] $types
*/
public function __construct(
private ?int $limit = null,
private ?array $notSenders = null,
private ?array $notTypes = null,
private ?array $senders = null,
private ?array $types = null,
)
{
if (! is_null($limit) && $limit <= 0) {
throw new \InvalidArgumentException("limit must be an integer greater than 0");
}
}
public function jsonSerialize(): array
{
return array_filter([
"limit" => $this->limit,
"not_senders" => $this->notSenders,
"not_types" => $this->notTypes,
"senders" => $this->senders,
"types" => $this->types,
], fn ($value) => ! is_null($value));
}
}
|