FluidTYPO3\Vhs\ViewHelpers\Condition\Iterator\ContainsViewHelper::getNeedleAtIndex PHP Method

getNeedleAtIndex() protected static method

protected static getNeedleAtIndex ( integer $index, array $arguments ) : mixed
$index integer
$arguments array
return mixed
    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;
    }