protected function isLast($i, $from, $to, $step) { if ($from === $to) { $isLast = true; } elseif ($from < $to) { $isLast = $i + $step > $to; } else { $isLast = $i + $step < $to; } return $isLast; }