Skip to content

Commit

Permalink
Adds Collection->flatMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
kapxapot committed May 3, 2020
1 parent ff6c949 commit b50b776
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ public function whereNotIn(string $column, $values) : self
return static::make($data);
}

/**
* Shortcut for map()->flatten().
*/
public function flatMap(callable $func) : Collection
{
return $this
->map($func)
->flatten();
}

public function map(callable $func) : Collection
{
$data = array_map($func, $this->data);
Expand Down

0 comments on commit b50b776

Please sign in to comment.