public function readIdentifier($prefix = null, $allowedChars = null)
    {
        if ($prefix) {
            if ($this->peek(mb_strlen($prefix)) !== $prefix) {
                return;
            }

            $this->consume();
        } elseif (!$this->peekAlphaIdentifier($allowedChars)) {
            return;
        }

        return $this->readWhile(function () use ($allowedChars) {
            return $this->peekIdentifier($allowedChars);
        });
    }
public function readIdentifier($prefix = null, $allowedChars = null)
    {
        if ($prefix) {
            if ($this->peek(mb_strlen($prefix)) !== $prefix) {
                return;
            }

            $this->consume();
        } elseif (!$this->peekAlphaIdentifier($allowedChars)) {
            return;
        }

        return $this->readWhile(function () use ($allowedChars) {
            return $this->peekIdentifier($allowedChars);
        });
    }
public function readIdentifier ( $ prefix = null , $ allowedChars = null ) { if ( $ prefix ) { if ( $ this -> peek ( mb_strlen ( $ prefix ) ) !== $ prefix ) { return ; } $ this -> consume ( ) ; } elseif ( ! $ this -> peekAlphaIdentifier ( $ allowedChars ) ) { return ; } return $ this -> readWhile ( function ( ) use ( $ allowedChars ) { return $ this -> peekIdentifier ( $ allowedChars ) ; } ) ; }
Reads an upcoming alpha-numeric identifier in a string.

Identifiers start with an alphabetical character and then follow with alpha-numeric characters.

@param string $prefix       the prefix for an identifier (e.g. $, @, % etc., default: none)
@param array  $allowedChars additional chars to allow in the identifier (default: ['_'])

@return string|null the resulting identifier or null of none encountered.
Reads an upcoming alpha - numeric identifier in a string .