summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Filters/EventFilter.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Data/Filters/EventFilter.php')
-rw-r--r--matrix-specification/Data/Filters/EventFilter.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/matrix-specification/Data/Filters/EventFilter.php b/matrix-specification/Data/Filters/EventFilter.php
new file mode 100644
index 0000000..98788ad
--- /dev/null
+++ b/matrix-specification/Data/Filters/EventFilter.php
@@ -0,0 +1,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,
+ ], "is_null");
+ }
+}