Gregwar\RST\Parser::parseListLine PHP Метод

parseListLine() защищенный Метод

Parses a list line
protected parseListLine ( string $line ) : array
$line string the string line
Результат array containing: - true if the list is ordered, false else - the depth of the list - the text of the first line without the tick
    protected function parseListLine($line)
    {
        $depth = 0;
        for ($i = 0; $i < strlen($line); $i++) {
            $char = $line[$i];
            if ($char == ' ') {
                $depth++;
            } else {
                if ($char == "\t") {
                    $depth += 2;
                } else {
                    break;
                }
            }
        }
        if (preg_match('/^((\\*|\\-)|([\\d#]+)\\.) (.+)$/', trim($line), $match)) {
            return array('prefix' => $line[$i], 'ordered' => $line[$i] == '*' || $line[$i] == '-' ? false : true, 'depth' => $depth, 'text' => array($match[4]));
        }
        return false;
    }