We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e96dc4f commit d399959Copy full SHA for d399959
src/DataTransferObject/Collection.php
@@ -12,7 +12,7 @@
12
final class Collection implements \IteratorAggregate, \Countable
13
{
14
/** @var list<T> */
15
- public array $items;
+ private array $items;
16
17
/**
18
* @param list<T> $items
@@ -39,4 +39,22 @@ public function count(): int
39
40
return count($this->items);
41
}
42
+
43
+ /**
44
+ * @param callable(T):bool $callback
45
+ *
46
+ * @return self<T>
47
+ */
48
+ public function filter(callable $callback): self
49
+ {
50
+ return new self(array_values(array_filter($this->items, $callback)));
51
+ }
52
53
54
+ * @return list<T>
55
56
+ public function toArray(): array
57
58
+ return $this->items;
59
60
0 commit comments