protected static function assertHaystackIsQueryResultAndHasNeedle($haystack, $needle)
{
if (true === $needle instanceof DomainObjectInterface) {
/** @var $needle DomainObjectInterface */
$needle = $needle->getUid();
}
foreach ($haystack as $index => $candidate) {
/** @var $candidate DomainObjectInterface */
if ((int) $candidate->getUid() === (int) $needle) {
return $index;
}
}
return false;
}