From 43fcb9f06114abfc5ff1432cdcc1b9f3fac6b8dc Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Wed, 9 Nov 2022 19:27:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20fi?= =?UTF-8?q?nd=20=D0=B2=20ArrayHelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Helpers/ArrayHelper.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Helpers/ArrayHelper.php b/src/Helpers/ArrayHelper.php index d4d4a51..e13821f 100755 --- a/src/Helpers/ArrayHelper.php +++ b/src/Helpers/ArrayHelper.php @@ -4,6 +4,12 @@ namespace Webmasterskaya\CryptoPro\Helpers; class ArrayHelper { + /** + * @param array $array + * @param callable $fn + * + * @return bool + */ public static function any(array $array, callable $fn) { foreach ($array as $value) @@ -17,6 +23,12 @@ class ArrayHelper return false; } + /** + * @param array $array + * @param callable $fn + * + * @return bool + */ public static function every(array $array, callable $fn) { foreach ($array as $value) @@ -29,4 +41,21 @@ class ArrayHelper return true; } + + /** + * @param array $array + * @param callable $fn + * + * @return mixed|void + */ + public static function find(array $array, callable $fn) + { + foreach ($array as $key => $value) + { + if ($fn($value, $key, $array)) + { + return $value; + } + } + } } \ No newline at end of file