protected function findStepByIndex($index)
{
/** @var array $steps */
$steps = $this->steps();
if ($index < 0 || $index >= count($steps)) {
throw new StepNotFoundException();
}
/** @var WizardStep $step */
$i = 0;
foreach ($steps as $id => $step) {
if ($i == $index) {
return $step;
}
++$i;
}
throw new StepNotFoundException();
}