protected static function assertHaystackIsArrayAndHasNeedle($haystack, $needle, $arguments)
{
if (false === $needle instanceof DomainObjectInterface) {
if (true === (bool) $arguments['considerKeys']) {
$result = (bool) (false !== array_search($needle, $haystack) || true === isset($haystack[$needle]));
} else {
$result = array_search($needle, $haystack);
}
return $result;
} else {
/** @var $needle DomainObjectInterface */
foreach ($haystack as $index => $straw) {
/** @var $straw DomainObjectInterface */
if ((int) $straw->getUid() === (int) $needle->getUid()) {
return $index;
}
}
}
return false;
}