mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-13 06:32:22 +00:00
11b6f003b8
a94a11a157
[Utils] Add ArrayChecker util to verify first data found on given array (#3262)
23 lines
471 B
PHP
23 lines
471 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Core\Util;
|
|
|
|
final class ArrayChecker
|
|
{
|
|
/**
|
|
* @param mixed[] $elements
|
|
* @param callable(mixed $element): bool $callable
|
|
*/
|
|
public function doesExist(array $elements, callable $callable) : bool
|
|
{
|
|
foreach ($elements as $element) {
|
|
$isFound = $callable($element);
|
|
if ($isFound) {
|
|
return \true;
|
|
}
|
|
}
|
|
return \false;
|
|
}
|
|
}
|