PhpCss\Scanner::scan PHP Method

scan() public method

Scan a string for tokens
public scan ( &$target, string $string, integer $offset ) : integer
$string string content string
$offset integer start offset
return integer new offset
    public function scan(&$target, $string, $offset = 0)
    {
        $this->_buffer = $string;
        $this->_offset = $offset;
        while ($token = $this->_next()) {
            $target[] = $token;
            // switch back to previous scanner
            if ($this->_status->isEndToken($token)) {
                return $this->_offset;
            }
            // check for status switch
            if ($newStatus = $this->_status->getNewStatus($token)) {
                // delegate to subscanner
                $this->_offset = $this->_delegate($target, $newStatus);
            }
        }
        if ($this->_offset < strlen($this->_buffer)) {
            /**
             * @todo a some substring logic for large strings
             */
            throw new Exception\InvalidCharacter($this->_buffer, $this->_offset, $this->_status);
        }
        return $this->_offset;
    }