mirror of
https://github.com/crypto-pro-web/crypto-pro-php.git
synced 2025-01-18 11:25:50 +03:00
Добавил find в ArrayHelper
This commit is contained in:
parent
84dd8b6dfd
commit
43fcb9f061
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user