Skip to content

Commit 33afbf1

Browse files
committed
added filter method to FluentList
1 parent 287bc98 commit 33afbf1

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/Support/FluentList.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@ public function snakeKeys(): self
225225
return $this;
226226
}
227227

228-
public function column($column_key, $index_key = null): array
229-
{
230-
return array_column($this->items, $column_key, $index_key);
231-
}
232-
233228
public function shuffle(): self
234229
{
235230
shuffle($this->items);
@@ -252,9 +247,23 @@ public function localized(): self
252247
return Obj::localize($this, Language::getCurrent());
253248
}
254249

250+
public function column($column_key, $index_key = null): array
251+
{
252+
return array_column($this->items, $column_key, $index_key);
253+
}
254+
255+
// TODO maybe should return the result instead of changing the source data, just like column above
256+
// if so, change on profilePosters
255257
public function slice(int $offset, int $length = null): self
256258
{
257259
$this->items = array_slice($this->items, $offset, $length);
258260
return $this;
259261
}
262+
263+
// TODO maybe should return the result instead of changing the source data, just like column above
264+
public function filter(callable $callback = null): self
265+
{
266+
$this->items = array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH);
267+
return $this;
268+
}
260269
}

0 commit comments

Comments
 (0)