League\CommonMark\Cursor::peek PHP Method

peek() public method

Returns the next character (or null, if none) without advancing forwards
public peek ( integer $offset = 1 ) : string | null
$offset integer
return string | null
    public function peek($offset = 1)
    {
        return $this->getCharacter($this->currentPosition + $offset);
    }

Usage Example

Beispiel #1
0
 public function matchesNextLine(Cursor $cursor)
 {
     if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() == 'A') {
         $cursor->advanceToFirstNonSpace();
         if ($cursor->peek() === '>') {
             $cursor->advanceBy(2);
             if ($cursor->getCharacter() === ' ') {
                 $cursor->advance();
             }
             return true;
         }
     }
     return false;
 }
All Usage Examples Of League\CommonMark\Cursor::peek