find the line mode

@param string $line line content
178178
private function findMode(string $line)
    {
        if (preg_match('/^index (.*)\.\.(.*) (.*)$/', $line)) {
            $this->mode = self::MODE_INDEX;
        }

        if (preg_match('/^mode (.*)\.\.(.*) (.*)$/', $line)) {
            $this->mode = self::MODE_MODE;
        }

        if (preg_match('/^new file mode (.*)/', $line)) {
            $this->mode = self::MODE_NEW_FILE;
        }

        if (preg_match('/^deleted file mode (.*)/', $line)) {
            $this->mode = self::MODE_DELETED_FILE;
        }
    }
1289271
protected function isImmediate( $line )
	{
		$code = "";
		$sq = $dq = false;
		for( $i = 0; $i < strlen( $line ); $i++ )
		{
			$c = $line{$i};
			if( $c == "'" )
				$sq = !$sq;
			else if( $c == '"')
				$dq = !$dq;
			else if( ( $sq ) ||( $dq ) )
			{
				if( $c == "\\" )
					$i++;
			}
			else
				$code .= $c;
		}
		$code = str_replace( $this->okeq, "", $code );
		if( strcspn( $code, ";{=" ) != strlen( $code ) )
			return false;
		$kw = split( "[^A-Za-z0-9_]", $code );
		foreach( $kw as $i )
			if( in_array( $i, $this->skip ) )
				return false;
		return true;
	}
678954
private function parseHeaderLine($line)
    {
        $matches = [];
        if (preg_match('/^([^:]+):(.*)$/', $line, $matches) === 1) {
            $this->addHeader(trim($matches[1]), trim($matches[2]));
        }
    }
430344
static function parse_line($line)
    {
        $line = trim($line);
        $result = array();
        $datas = explode(self::$col_sep, $line);
        if (empty(self::$data_sep))
        {
            return $datas;
        }
        foreach ($datas as $data)
        {
            $d = self::parse_data($data);
            if (empty($d[0]))
            {
                continue;
            }
            $result[trim($d[0])] = trim($d[1]);
        }
        return $result;
    }
609522
private function isHeaderOpLine(string $line): bool
    {
        $matches = [];
        if (preg_match('#^(old|new|deleted|rename|copy) (file mode|from|to) (.+)#', $line, $matches)) {
            $this->currentOperation = self::$opsMap[$matches[1]];
            return true;
        }
        return false;
    }
871720
protected function validateLine($line)
    {
        $line = trim($line);

        $parts = explode(',', $line);
        $parts = array_filter($parts);

        foreach ($parts as $part) {
            if (!$this->validatePart($part)) {
                return false;
            }
        }

        return true;
    }
865795
protected function _parseLine( $line )
    {
        $_result = str_getcsv(
            $line,
            $this->_separator,
            $this->_enclosure,
            EscapeStyle::SLASHED == $this->_escapeStyle ? '\\' : EscapeStyle::DOUBLED == $this->_escapeStyle ? '"' : ''
        );

        return $_result;
    }
1234945
protected function isComment($line)
    {
        if (is_string($line) && (substr($line, 0, 1) == ';' || trim($line) == '')) {
            return true;
        }

        return false;
    }
381781
protected function parseLine(&$line)
    {
        switch ($this->state) {
        case self::STATE_BEGIN:
            if (trim($line)) {
                if ($this->isListLine($line)) {
                    $this->state = self::STATE_LIST;
                    $this->buffer = $this->kernel->build('Nodes\ListNode');
                    $this->lineInfo = null;
                    $this->listFlow = true;
                    return false;
                } else if ($this->isBlockLine($line)) {
                    if ($this->isCode) {
                        $this->state = self::STATE_CODE;
                    } else {
                        $this->state = self::STATE_BLOCK;
                    }
                    return false;
                } else if ($this->isDirective($line)) {
                    $this->state = self::STATE_DIRECTIVE;
                    $this->buffer = array();
                    $this->flush();
                    $this->initDirective($line);
                } else if ($this->parseLink($line)) {
                    return true;
                } else if ($parts = $this->parseTableLine($line)) {
                    $this->state = self::STATE_TABLE;
                    $this->buffer = $this->kernel->build('Nodes\TableNode', $parts);
                } else {
                    $this->state = self::STATE_NORMAL;
                    return false;
                }
            }
            break;

        case self::STATE_LIST:
            if (!$this->pushListLine($line)) {
                $this->flush();
                $this->state = self::STATE_BEGIN;
                return false;
            }
            break;

        case self::STATE_TABLE:
            if (!trim($line)) {
                $this->flush();
                $this->state = self::STATE_BEGIN;
            } else {
                $parts = $this->parseTableLine($line);

                if (!$this->buffer->push($parts, $line)) {
                    $this->flush();
                    $this->state = self::STATE_BEGIN;
                    return false;
                }
            }

            break;

        case self::STATE_NORMAL:
            if (trim($line)) {
                $specialLetter = $this->isSpecialLine($line);

                if ($specialLetter) {
                    $this->specialLetter = $specialLetter;
                    $lastLine = array_pop($this->buffer);

                    if ($lastLine) {
                        $this->buffer = array($lastLine);
                        $this->state = self::STATE_TITLE;
                    } else {
                        $this->buffer[] = $line;
                        $this->state = self::STATE_SEPARATOR;
                    }
                    $this->flush();
                    $this->state = self::STATE_BEGIN;
                } else {
                    if ($this->isDirective($line)) {
                        $this->flush();
                        $this->state = self::STATE_BEGIN;
                        return false;
                    }
                    if ($this->isComment($line)) {
                        $this->flush();
                        $this->state = self::STATE_COMMENT;
                    } else {
                        $this->buffer[] = $line;
                    }
                }
            } else {
                $this->flush();
                $this->state = self::STATE_BEGIN;
            }
            break;
        
        case self::STATE_COMMENT:
            $isComment = false;

            if (!$this->isComment($line) && (!trim($line) || $line[0] != ' ')) {
                $this->state = self::STATE_BEGIN;
                return false;
            }
            break;

        case self::STATE_BLOCK:
        case self::STATE_CODE:
            if (!$this->isBlockLine($line)) {
                $this->flush();
                $this->state = self::STATE_BEGIN;
                return false;
            } else {
                $this->buffer[] = $line;
            }
            break;

        case self::STATE_DIRECTIVE:
            if (!$this->directiveAddOption($line)) {
                if ($this->isDirective($line)) {
                    $this->flush();
                    $this->initDirective($line);
                } else {
                    $directive = $this->getCurrentDirective();
                    $this->isCode = $directive ? $directive->wantCode() : false;
                    $this->state = self::STATE_BEGIN;
                    return false;
                }
            }
            break;

        default:
            $this->getEnvironment()->getErrorManager()->error('Parser ended in an unexcepted state');
        }

        return true;
    }
1201366
public function parseLine($line) {

        $data = explode(";", $line);
        $i    = -1;

        $model = new StartRecordFormat();
        $model->setVersionRecordStructure(IntegerHelper::parseString($data[++$i]));
        $model->setFacilityNumber(IntegerHelper::parseString($data[++$i]));
        $model->setDateFile($this->decodeDate($data[++$i]));
        $model->setNumberRecords(IntegerHelper::parseString($data[++$i]));
        $model->setCurrency($this->decodeString($data[++$i]));

        return $model;
    }
1103531
protected function parseDocControlLine( Line$line ):self
	{
		switch( $name= $line->pregGet('/(?<=^@)[\w-:]+/') ){
			default:{
				$this->throw("The @$name is not supported.");
			}break;
			case 'extend':{
				$this->throw('The @extend can only be used on first line.');
			}break;
			case 'include':{
				$this->include($line);
			}break;
			case 'section':{
				$this->defineSection($line);
			}break;
			case 'show':{
				$this->showSection($line);
			}break;
		}

		return $this;
	}
207875
protected function isListLine($line)
    {
        // A buffer is a list if at least the first line is a list-style
        $listLine = $this->parseListLine($line);

        if ($listLine) {
            return $listLine['depth'] == 0 || !$this->isCode;
        }

        return false;
    }
215139
protected function parse_line($line) {
        $data = array();
        foreach ($line as $keynum => $value) {
            if (!isset($this->columns[$keynum])) {
                // This should not happen.
                continue;
            }

            $key = $this->columns[$keynum];
            $data[$key] = $value;
        }
        return $data;
    }
565096
public function addLine(Line $line)
    {
        $this->lines[] = $line;
        $this->end = $line->getIndex();
    }
173106
private static function parseContent(string $line): array
    {
        /* Get position of separator */
        $separatePosition = strpos($line, self::$separator);

        /* Get config key */
        $configName = trim(substr($line, 0, $separatePosition));

        /* Get config value */
        $configValue = trim(rtrim(substr($line, $separatePosition + strlen(self::$separator)), "\n"));

        /* Transform config value to number */
        if (is_numeric($configValue)) {
            /* Is int */
            if ((int)$configValue == $configValue) {
                $configValue = (int)$configValue;
            }

            /* Is float */
            else {
                $configValue = (float)$configValue;
            }
        }

        return ['key' => $configName, 'value' => $configValue];
    }
1313503
private function parseCodeLine(string $line): Line
    {
        if (strlen($line) == 0) {
            return new Line(Line::EXISTED, '');
        }

        $firstChar = $line[0];
        $cleanLine = rtrim(substr($line, 1));

        return new Line(Line::$opsMap[$firstChar], $cleanLine);
    }
451069
public static function getLineSlices(string $line)
    {
        preg_match('/^(\d+) (\w+) ([a-z0-9]+) +(\d+|-)\t(.*)$/', $line, $matches);
        $permissions = $matches[1];
        $type = null;
        switch ($matches[2]) {
            case NodeObject::TYPE_TREE:
                $type = NodeObject::TYPE_TREE;
                break;
            case NodeObject::TYPE_BLOB:
                $type = NodeObject::TYPE_BLOB;
                break;
            case NodeObject::TYPE_LINK:
                $type = NodeObject::TYPE_LINK;
                break;
        }
        $sha = $matches[3];
        $size = $matches[4];
        $fullPath = $matches[5];

        return [
            'permissions' => $permissions,
            'type'        => $type,
            'sha'         => $sha,
            'size'        => $size,
            'fullPath'    => $fullPath,
        ];
    }