From 8f4edd21062b56668ccab7fa516246df4e6bc070 Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Mon, 4 Jul 2022 13:26:50 +0700 Subject: [PATCH] add contains? function for collections --- src/Lib/Collections.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Lib/Collections.php b/src/Lib/Collections.php index 808ee39..39f8ac5 100644 --- a/src/Lib/Collections.php +++ b/src/Lib/Collections.php @@ -72,6 +72,10 @@ class Collections implements ILib } )); + $env->set('contains?', new CoreFunc('contains?', 'Return true if first argument (collection) contains the second argument. Use optional third argument for strict comparison.', 2, 3, + fn (Seq $a, $b, bool $strict = false) => in_array($b, $a->getData(), $strict) + )); + $env->set('get', new CoreFunc('get', 'Get the item from first argument (collection) by using the second argument as index or key.', 2, 2, fn (Collection $a, $b) => $a->get($b) ));