<?php

namespace SGalinski\TypoScriptReferenceFrontend\ViewHelpers;

use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;

/**
 * Class AccessArrayViewHelper renders value of the specified array at the specified index position.
 *
 * @package SGalinski\TypoScriptReferenceFrontend\ViewHelpers
 */
class AccessArrayViewHelper extends AbstractViewHelper {
	/**
	 * Renders content of $array's element with index $index
	 *
	 * @param array $array
	 * @param string|int $index
	 * @return string
	 */
	public function render($array, $index) {
		if (gettype($array) !== 'array') {
			return '';
		}
		return $array[$index];
	}
}