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