public function render()
{
$a = $this->getInlineArgument();
$aIsIterable = $this->assertIsArrayOrIterator($a);
if (true === $aIsIterable) {
$a = $this->arrayFromArrayOrTraversableOrCSV($a);
sort($a, SORT_NUMERIC);
$size = count($a);
$midpoint = $size / 2;
if (1 === $size % 2) {
/*
* Array indexes of float are truncated to integers,
* not everybody knows, let's make it explicit for everybody
* wondering.
*/
return $a[(int) $midpoint];
}
$candidates = array_slice($a, floor($midpoint) - 1, 2);
return array_sum($candidates) / 2;
}
return $a;
}