protected function matchTokenTextAtCursor(int $type)
    {
        $result = preg_match($this->getTokenPattern($type), $this->getTextAtCursor(), $matches);
        PregHelper::assertMatchResult(
            $result,
            RegExpException::class,
            "Failed to match token text due to regular expression error"
        );
        if (1 === $result) {
            $text = $matches[0];
            if (strlen($text) == 0) {
                throw new LengthException("Matched token text is empty");
            }
        } else {
            $text = null;
        }
        return $text;
    }
protected function matchTokenTextAtCursor(int $type)
    {
        $result = preg_match($this->getTokenPattern($type), $this->getTextAtCursor(), $matches);
        PregHelper::assertMatchResult(
            $result,
            RegExpException::class,
            "Failed to match token text due to regular expression error"
        );
        if (1 === $result) {
            $text = $matches[0];
            if (strlen($text) == 0) {
                throw new LengthException("Matched token text is empty");
            }
        } else {
            $text = null;
        }
        return $text;
    }
protected function matchTokenTextAtCursor ( int $ type ) { $ result = preg_match ( $ this -> getTokenPattern ( $ type ) , $ this -> getTextAtCursor ( ) , $ matches ) ; PregHelper :: assertMatchResult ( $ result , RegExpException :: class , "Failed to match token text due to regular expression error" ) ; if ( 1 === $ result ) { $ text = $ matches [ 0 ] ; if ( strlen ( $ text ) == 0 ) { throw new LengthException ( "Matched token text is empty" ) ; } } else { $ text = null ; } return $ text ; }
Checks if text at current cursor position starts from token of given type.

@param int $type
@return string|null Token text or NULL.
@todo Split method in two.
Checks if text at current cursor position starts from token of given type .