stringHelper = $stringHelper; } /** * Move the the cursor to the next position. * Will always move the cursor, even if the end of the string has been passed. * * @return string|null */ public function readNext() { $this->position++; return $this->readCurrent(); } /** * Returns the current character. * * @return string|null */ public function readCurrent() { if ($this->hasCurrent()) { $char = $this->input[$this->position]; } else { $char = null; } return $char; } /** * Returns true if there is a character at the current position * * @return bool */ public function hasCurrent() { return ($this->position < strlen($this->input)); } /** * Resets the position of the cursor to the beginning of the string. * * @return void */ public function reset() { $this->position = 0; } /** * Setter for the input string * * @param string $input */ public function setInput($input) { $this->stringHelper->validate($input); $this->input = $input; } /** * Getter for the input string * * @return string */ public function getInput() { return $this->input; } /** * Getter for the cursor position * * @return int */ public function getPosition() { return $this->position; } }