Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit e44e5e3

Browse files
author
Nik Barham
committed
Adding map function to Collection
1 parent b761c3e commit e44e5e3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Automatorm/Orm/Collection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ public function remove($filter)
313313
{
314314
return $this->filter($filter, true);
315315
}
316+
317+
public function map(callable $function)
318+
{
319+
$copy = $this->container;
320+
array_walk($copy, $function);
321+
return new static($copy);
322+
}
316323

317324
// Only keep items that match filter
318325
public function filter($filter, $invert_prefix = false)

0 commit comments

Comments
 (0)