protected static function getNeedleAtIndex($index, $arguments)
{
if (0 > $index) {
return null;
}
$haystack = $arguments['haystack'];
$asArray = [];
if (true === is_array($haystack)) {
$asArray = $haystack;
} elseif (true === $haystack instanceof LazyObjectStorage) {
/** @var $haystack LazyObjectStorage */
$asArray = $haystack->toArray();
} elseif (true === $haystack instanceof ObjectStorage) {
/** @var $haystack ObjectStorage */
$asArray = $haystack->toArray();
} elseif (true === $haystack instanceof QueryResult) {
/** @var $haystack QueryResult */
$asArray = $haystack->toArray();
} elseif (true === is_string($haystack)) {
$asArray = str_split($haystack);
}
return true === isset($asArray[$index]) ? $asArray[$index] : false;
}