Detect and extract block with YAML frontmatter from the lines array.

@param string $line to begin parsing.

@return boolean|void true when block is found and parsed, else void.

@SuppressWarnings(PHPMD.CyclomaticComplexity)
176605
protected function blockYamlFrontmatter($line)
    {
        if ($this->config["frontmatter_yaml"]
            && strlen($line) === 3
            && $line[2] === "-"
            && $line[1] === "-"
        ) {
            $startLineNumber = $this->lineNumber;

            // Detect end of block and move it to frontmatter
            while (($line = $this->nextLine()) !== false) {
                $line = rtrim($line);

                // Block ends with --- or ...
                if (strlen($line) === 3
                    && (
                    ($line[2] === "-" && $line[1] === "-" && $line[0] === "-") ||
                    ($line[2] === "." && $line[1] === "." && $line[0] === ".")
                    )
                ) {
                    $linesRemoved = $this->lineNumber + 1 - $startLineNumber;
                    $this->linesRemoved += $linesRemoved;
                    $frontmatter = array_splice(
                        $this->lines,
                        $startLineNumber - 1,
                        $linesRemoved
                    );

                    unset($frontmatter[$linesRemoved - 1]);
                    unset($frontmatter[0]);
                    $this->addYamlFrontmatter($frontmatter);
                    $this->lineNumber = $startLineNumber - 1;

                    return true;
                }
            }

            if ($this->currentLine() === false) {
                throw new Exception("Start of YAML detected at line: $startLineNumber but no end of block detected.");
            }
        }
    }
1279
protected function parseTag($line) {
		$matches = [];
		if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $line, $matches)) {
			throw new \InvalidArgumentException('Invalid tag line detected: ' . $line);
		}
		
		$tagName = $matches[1];
		$content = isset($matches[2]) ? $matches[2] : '';
		
		return TagFactory::create($tagName, $content);
	}
973186
protected function formatLine($line)
    {
        if ($line instanceof Htmlable) {
            return $line;
        }

        if (is_array($line)) {
            return implode(' ', array_map('trim', $line));
        }

        return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line))));
    }
614105
private function isPrompt($line) {
		return mb_substr($line, 0, self::DELIMITER_LENGTH) === self::DELIMITER || $line === false;
	}
641323
protected function formatLine($line)
    {
        if (is_array($line)) {
            return implode(' ', array_map('trim', $line));
        }

        return trim(implode(' ', array_map('trim', explode(PHP_EOL, $line))));
    }
1123452
protected function isSpecialLine($line)
    {
        if (strlen($line) < 3) {
            return false;
        }

        $letter = $line[0];

        $environment = $this->environment;
        if (!in_array($letter, $environment::$letters)) {
            return false;
        }

        for ($i=1; $i<strlen($line); $i++) {
            if ($line[$i] != $letter) {
                return false;
            }
        }

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

        return false;
    }
154931
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;
    }
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;
	}
963
private function isHeaderLine(string $line): bool
    {
        $matches = [];
        if (preg_match('#^diff --git [a|b|c|i|w|o]/(.*) [a|b|c|i|w|o]/(.*)#', $line, $matches)) {
            $this->appendCollectedFileAndChanges();
            $this->currentOperation = File::OP_MODIFIED;
            $this->currentFileName  = $matches[2];
            return true;
        }
        return false;
    }
686371
public function validateLine($line)
    {
        $invalidExtensions = [
            '.jpg',
            '.js',
            '.css',
            '.sass',
            '.scss',
            '.png',
            '.svg',
            '.ico',
            '.jpeg',
            '.gif',
            '.mp4',
        ];

        foreach ($invalidExtensions as $needle) {
            if (stristr($line->URL, $needle)) {
                return false;
            }
        }

        if ($line->HeaderUserAgent === 'MissionControlAgent') {
            return false;
        }

        return true;
    }
451414
private function interpretApacheInfoData(string $line) : bool
    {
        $retval = false;
        $parts = preg_split('/:\s+/', $line, 2);
        if (count($parts) === 2) {
            switch (trim($parts[0])) {
                case 'Server version':
                    $this->apache_info['server-version'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'Server built':
                    $this->apache_info['server-built'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'Server\'s Module Magic Number':
                    $this->apache_info['server-magic-number'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'Architecture':
                    $this->apache_info['server-architecture'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'Server MPM':
                    $this->apache_info['server-mpm'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'threaded':
                    $this->apache_info['server-mpm-threaded'] = trim($parts[1]);
                    $retval = true;
                    break;
                case 'forked':
                    $this->apache_info['server-mpm-forked'] = trim($parts[1]);
                    $retval = true;
                    break;
                default:
            }
        }

        return $retval;
    }
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;
        }
    }
954594
protected function blockQuote($Line)
    {
        if (!$this->config('markup.quote.keepSigns'))
        {
            return parent::blockQuote($Line);
        }

        if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches))
        {
            $matches = str_replace(">", "&gt;", $matches[1]);
            $Block = array(
                'element' => array(
                    'name' => 'blockquote',
                    'handler' => 'lines',
                    'text' => [ "&gt;{$matches}" ],
                ),
            );

            return $Block;
        }
    }
1202714
protected function isParagraphEnd($line)
	{
		if (empty($line) ||
			ltrim($line) === '' ||
			$this->identifyHeadline($line) ||
			$this->identifyHr($line) ||
			$this->identifyUl($line) ||
			$this->identifyOl($line) ||
			$this->identifyTable($line) ||
			$this->identifyCode($line) ||
			$this->identifyRawHtml($line))
		{
			return true;
		}
		return false;
	}
923971
public function handleEvent(string $line)
    {
        $line = trim($line, "\0");
        if ($line === self::BATCH_END) {
            $this->handleBatch();

            return;
        }

        list($eventsString, $path) = explode(':', $line, 2);
        $events = explode(' ', $eventsString);
        $path = rtrim($path, '/');
        foreach ($events as $event) {
            $this->batchEvents[$path][$event] = true;
        }
    }
352280
private function parseLine($line)
    {
        if (($pair = $this->generateRulePair($line, array_keys(self::TOP_LEVEL_DIRECTIVES))) !== false) {
            return $this->handler->{self::TOP_LEVEL_DIRECTIVES[$pair[0]]}->add($pair[1]);
        }