PHP Класс League\CommonMark\Cursor

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( string $line )
advance ( ) Move the cursor forwards
advanceBy ( integer $characters, $advanceByColumns = false ) Move the cursor forwards
advanceBySpaceOrTab ( ) : boolean Advances the cursor by a single space or tab, if present
advanceToEnd ( ) : integer Move the position to the very end of the line
advanceToFirstNonSpace ( ) : integer Parse zero or more space characters, including at most one newline
advanceWhileMatches ( string $character, integer | null $maximumCharactersToAdvance = null ) : integer Advances the cursor while the given character is matched
getCharacter ( integer | null $index = null ) : string | null
getColumn ( ) : integer
getFirstNonSpaceCharacter ( ) : string Returns the next character which isn't a space
getFirstNonSpacePosition ( ) : integer Returns the position of the next non-space character
getIndent ( ) : integer Calculates the current indent (number of spaces after current position)
getLine ( ) : string
getPosition ( ) : integer
getPreviousText ( ) : string
getRemainder ( ) : string
isAtEnd ( ) : boolean
isBlank ( ) : boolean Whether the remainder is blank
isIndented ( ) : boolean Whether the cursor is indented to INDENT_LEVEL
match ( string $regex ) : string | null Try to match a regular expression
peek ( integer $offset = 1 ) : string | null Returns the next character (or null, if none) without advancing forwards
restoreState ( CursorState $state )
saveState ( ) : CursorState

Описание методов

__construct() публичный метод

public __construct ( string $line )
$line string

advance() публичный метод

Move the cursor forwards
public advance ( )

advanceBy() публичный метод

Move the cursor forwards
public advanceBy ( integer $characters, $advanceByColumns = false )
$characters integer Number of characters to advance by

advanceBySpaceOrTab() публичный метод

Advances the cursor by a single space or tab, if present
public advanceBySpaceOrTab ( ) : boolean
Результат boolean

advanceToEnd() публичный метод

Move the position to the very end of the line
public advanceToEnd ( ) : integer
Результат integer The number of characters moved

advanceToFirstNonSpace() публичный метод

Parse zero or more space characters, including at most one newline
public advanceToFirstNonSpace ( ) : integer
Результат integer Number of positions moved

advanceWhileMatches() публичный метод

Advances the cursor while the given character is matched
public advanceWhileMatches ( string $character, integer | null $maximumCharactersToAdvance = null ) : integer
$character string Character to match
$maximumCharactersToAdvance integer | null Maximum number of characters to advance before giving up
Результат integer Number of positions moved (0 if unsuccessful)

getCharacter() публичный метод

public getCharacter ( integer | null $index = null ) : string | null
$index integer | null
Результат string | null

getColumn() публичный метод

public getColumn ( ) : integer
Результат integer

getFirstNonSpaceCharacter() публичный метод

Returns the next character which isn't a space
public getFirstNonSpaceCharacter ( ) : string
Результат string

getFirstNonSpacePosition() публичный метод

Returns the position of the next non-space character
public getFirstNonSpacePosition ( ) : integer
Результат integer

getIndent() публичный метод

Calculates the current indent (number of spaces after current position)
public getIndent ( ) : integer
Результат integer

getLine() публичный метод

public getLine ( ) : string
Результат string

getPosition() публичный метод

public getPosition ( ) : integer
Результат integer

getPreviousText() публичный метод

public getPreviousText ( ) : string
Результат string

getRemainder() публичный метод

public getRemainder ( ) : string
Результат string

isAtEnd() публичный метод

public isAtEnd ( ) : boolean
Результат boolean

isBlank() публичный метод

Whether the remainder is blank
public isBlank ( ) : boolean
Результат boolean

isIndented() публичный метод

Whether the cursor is indented to INDENT_LEVEL
public isIndented ( ) : boolean
Результат boolean

match() публичный метод

Returns the matching text and advances to the end of that match
public match ( string $regex ) : string | null
$regex string
Результат string | null

peek() публичный метод

Returns the next character (or null, if none) without advancing forwards
public peek ( integer $offset = 1 ) : string | null
$offset integer
Результат string | null

restoreState() публичный метод

public restoreState ( CursorState $state )
$state CursorState

saveState() публичный метод

public saveState ( ) : CursorState
Результат CursorState