From f25a9781bdf1672e61ac3547980b16a7fc0be9ce Mon Sep 17 00:00:00 2001 From: Fernando Pradas <5954976+fnandot@users.noreply.github.com> Date: Thu, 4 Jul 2019 09:29:16 +0200 Subject: [PATCH] Add flat_map function (#78) * Added flat_map function * Fixed flat_map tests * Added flat_map function * A little fix in flat_map readme * Modifed signature of flat_map and readme description * Removed an space * Modified description of flat_map example * Added flat_map to index * fixed flat_map comment style --- docs/docs.md | 1 + docs/functions/flat_map.md | 33 +++++++++++++++++++++++++++++++++ src/_bootstrap.php | 1 + src/flat_map.php | 25 +++++++++++++++++++++++++ tests/FlatMapTest.php | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 docs/functions/flat_map.md create mode 100644 src/flat_map.php create mode 100644 tests/FlatMapTest.php diff --git a/docs/docs.md b/docs/docs.md index 8ea226f..bfb1e07 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -16,6 +16,7 @@ * [filter](functions/filter.md): Discriminate the items of a collection for which function is false * [filter_null](functions/filter_null.md): Discriminate the items of a collection for which value is null * [first](functions/first.md): Returns the first element of a collection + * [flat_map](functions/flat_map.md): Returns an array containing the results of applying a given function to the items of a collection and flattening the results * [flatten](functions/flatten.md): Returns a flat collection from a multidimensional collection * [get](functions/get.md): Returns the value of an item in a collection or a default value in the case it does not exists * [get_in](functions/get_in.md): Returns the value in a nested associative structure or a default value in the case it does not exists diff --git a/docs/functions/flat_map.md b/docs/functions/flat_map.md new file mode 100644 index 0000000..ab5cf50 --- /dev/null +++ b/docs/functions/flat_map.md @@ -0,0 +1,33 @@ +# flat_map + +## Description +Returns an array containing the results of applying a given function to the items of a collection and flattening the results. + +## Parameters + +