From c8d15a8793537cf7c5887b7194d5f65ede44a6dd Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 20 Jul 2020 21:00:23 +0300 Subject: [PATCH] feat(element-queries): update collect() and collect_filter() #436 --- src/flextype/Support/helpers.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/flextype/Support/helpers.php b/src/flextype/Support/helpers.php index 05bf6a4c..cc71c488 100644 --- a/src/flextype/Support/helpers.php +++ b/src/flextype/Support/helpers.php @@ -10,25 +10,25 @@ declare(strict_types=1); use Flextype\Support\Collection; -if (! function_exists('collection')) { +if (! function_exists('collect')) { /** * Create a collection from the given value. * * @param mixed $value */ - function collection($items) : Collection + function collect($items) : Collection { return new Collection($items); } } -if (! function_exists('collection_filter')) { +if (! function_exists('collect_filter')) { /** - * Create a collection from the given value. + * Create a collection from the given value and filter it. * * @param mixed $value */ - function collection_filter($items, array $filter) : array + function collect_filter($items, array $filter) : array { $collection = new Collection($items); @@ -38,9 +38,6 @@ if (! function_exists('collection_filter')) { // Set Direction $direction = $collection->direction; - // Bind: recursive - $bind_recursive = $filter['recursive'] ?? false; - // Bind: set first result $bind_set_first_result = $filter['set_first_result'] ?? false; @@ -123,7 +120,7 @@ if (! function_exists('collection_filter')) { } // Gets a native PHP array representation of the collection. - $items = $collection->first(); + $items = $collection->all(); // Return entries return $items;