Parses YAML code and returns an array for a node
@access private
@return array
@param string $line A line from the YAML file
549934
private function parseLine($line)
    {
        if (!$line) {
            return array();
        }

        $line = trim($line);

        if (!$line) {
            return array();
        }

        $array = array();
        $group = $this->nodeContainsGroup($line);

        if ($group) {
            $this->addGroup($line, $group);
            $line = $this->stripGroup ($line, $group);
        }
        if ($this->startsMappedSequence($line)) {
            return $this->returnMappedSequence($line);
        }
        if ($this->startsMappedValue($line)) {
            return $this->returnMappedValue($line);
        }
        if ($this->isArrayElement($line)) {
            return $this->returnArrayElement($line);
        }
        if ($this->isPlainArray($line)) {
            return $this->returnPlainArray($line);
        }

        return $this->returnKeyValuePair($line);
    }
423585
protected function convertToArray(&$line)
    {
        $implodeStr = $this->multipleValueSeparator;
        $arr = array_map(
            function ($value, $key) use (&$implodeStr) {
                if (is_array($value) && is_numeric($key)) {
                    $this->convertToArray($value);
                    $implodeStr = '|';
                    return $value;
                }
                return sprintf("%s=%s", $key, $value);
            },
            $line,
            array_keys($line)
        );

        $line = implode(
            $implodeStr, $arr
        );
    }
586851
public static function parse($text) {
		
		self::setLineEndings();
		
		// set-up defaults
		$yaml     = array();
		$markdown = "";
		
		// read in the content
		// based on: https://github.com/mnapoli/FrontYAML/blob/master/src/Parser.php
		$lines = explode(PHP_EOL, $text);
		
		if (count($lines) <= 1) {
			$markdown = self::convertMarkdown($text);
			return array($yaml,$markdown);
		}
		
		if (rtrim($lines[0]) !== '---') {
			$markdown = self::convertMarkdown($text);
			return array($yaml,$markdown);
		}
		
		$head = array();
		unset($lines[0]);
		$i = 1;
		foreach ($lines as $line) {
			if ($line === '---') {
				break;
			}
			$head[] = $line;
			$i++;
		}
		
		$head = implode(PHP_EOL, $head);
		$body = implode(PHP_EOL, array_slice($lines, $i));
		
		$yaml     = self::convertYAML($head);
		$markdown = self::convertMarkdown($body);
		
		return array($yaml,$markdown);
		
	}
415197
public function parse($line)
    {
        if( !is_string($line) || strlen($line) === 0) {
            return array();
        }
        preg_match($this->pattern, $line, $data);
        if (!isset($data['date'])) {
            return array();
        }

        preg_match('/(.*)- Trace:(.*)/', $data['message'], $matches);
        if (is_array($matches) && isset($matches[1])) {
            $data['message'] = trim($matches[1]);
            $data['trace'] = trim($matches[2]);
        }

        return array(
            'date' => \DateTime::createFromFormat('Y-m-d H:i:s', $data['date']),
            'logger' => $data['logger'],
            'level' => $data['level'],
            'message' => $data['message'],
            'trace' => isset($data['trace']) ? $this->parseTrace($data['trace']) : null,
            'context' => json_decode($data['context'], true),
            'extra' => json_decode($data['extra'], true)
        );
    }
232864
private function parseDescription( $line ) {
		while ( preg_match('/{@([^}]*)}/', $line, $matches) ) {
			switch( $matches[1] ) {
				case 'internal' : 
					$line = str_replace( $matches[0], '', $line );
				break;
				default :
					$line = str_replace( $matches[0], $matches[1], $line );
				break;
			}
		}
		$line = str_replace( array( '\@', '{@*}' ), array( '@', '*/' ), $line );
		return $line;
	}
1120490
private function findTableChars(string $line) : ?array
    {
        $lineChar  = $line[0];
        $spaceChar = null;

        for ($i = 0; $i < strlen($line); $i++) {
            if ($line[$i] === $lineChar) {
                continue;
            }

            if ($spaceChar === null) {
                $spaceChar = $line[$i];

                continue;
            }

            if ($line[$i] !== $spaceChar) {
                return null;
            }
        }

        if ($spaceChar === null) {
            return null;
        }

        return [$lineChar, $spaceChar];
    }
1100203
private function getParamChunksFromLine($line)
    {
        $paramChunks = explode(' ', $line);
        $paramChunks = array_filter($paramChunks, function($val) {
            return $val !== '';
        });
        unset($paramChunks[0]);
        
        return $paramChunks;
    }
105317
private function chunk($line)
    {
        $width = $this->getWidth();
        if (mb_strlen($line) <= $width) {
            return [$line];
        }
        $stripped = $this->terminal->filter($line, static::REPLACEMENT_CHAR);
        $offset = 0;
        $out = [];

        for ($i = 0, $j = 0; $i <= mb_strlen($stripped); $i++) {
            if (mb_substr($stripped, $i, 1) != static::REPLACEMENT_CHAR) {
                if ($j > 0 && $j % $width == 0) {
                    $out[] = mb_substr($line, $offset, $i - $offset);
                    $offset = $i;
                }
                $j++;
            }
        }

        // return any remaining entries
        if ($offset != $i - 1) {
            $out[] = mb_substr($line, $offset);
        }
        return $out;
    }
638354
protected function parseMessages($lines) {
    $messages = array();

    $message = array();
    foreach ($lines as $line) {
      if (empty($line) & !empty($message)) {
        $messages[] = $message;
        $message = array();
        continue;
      }
      $message[] = $line;
    }

    return $messages;
  }
558541
protected function parse($file)
    {
        $data = json_decode(file_get_contents($file), true) ?: Yaml::parse(file_get_contents($file));

        return $data;
    }
1067753
private static function parseOneTemplateLine($line)
    {
        $line = trim($line);

        if (!$line) {
            return [];
        }

        $regex = '#\{\{(.*?)\}\}#';

        preg_match_all($regex, $line, $matches);

        $matched = array_map(function ($v) {
            return trim($v, '\'"{}');
        }, $matches[1]);

        return $matched;
    }
539352
private function parseConfigFile($file)
    {
        Assertion::file($file, 'Can\'t parse config file. File does not exist: ' . $file);

        $config = Yaml::parse(file_get_contents($file));

        if (is_null($config)) {
            $config = array();
        }

        return $config;
    }
1179542
protected function format($line)
    {
        if (is_array($line)) {
            return implode(' ', array_map('trim', $line));
        }

        $lines = preg_split('/\\r\\n|\\r|\\n/', $line);

        return trim(implode(' ', array_map('trim', $lines)));
    }
438166
protected function blockFencedCode($line)
    {
        $regex = '/^([' . $line[ 'text' ][ 0 ] . ']{3,})[ ]*([\w-]+)?[ ]*$/';

        if (preg_match($regex, $line[ 'text' ], $matches)) {
            $element = [
                'name' => 'code',
                'text' => '',
            ];

            if (isset($matches[ 2 ])) {
                $class = $this->getConfig('fenced_code_lang_class', 'prettyprint lang-{LANG}');
                $class = str_replace('{LANG}', $matches[2], $class); //'prettyprint lang-' . $matches[ 2 ];

                $element[ 'attributes' ] = [ 'class' => $class ];
            }

            $block = [
                'char'    => $line[ 'text' ][ 0 ],
                'element' => [
                    'name'    => 'pre',
                    'handler' => 'element',
                    'text'    => $element,
                ],
            ];

            return $block;
        }
    }
85451
public function parseMany($line)
    {
        $results = [];
        $buffer  = '';

        foreach (\str_split($line) as $character)
        {
            if ('{' == $character)
            {
                $buffer = $character;
            }
            elseif ('}' == $character)
            {
                $results[] = $this->parse($buffer.$character);
            }
            else
            {
                $buffer .= $character;
            }
        }

        return $results;
    }
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);
	}
889068
protected function getTranslationPhrases( $line )
    {
        $strings = array();
        $patternMatch1 = array();
        $patternMatch2 = array();

        preg_match_all( "/__\\(([\\\"'])(?:(?=(\\\\?))\\2.)*?\\1/u", $line, $patternMatch1); //for php and JS helper function
        preg_match_all( "/\{\{__ ['\"](.*?)['\"]\}\}/u", $line, $patternMatch2 ); //used for parsing templates

        if ( ! empty( $patternMatch1[0] )) {
            $strings = array_reduce(
                $patternMatch1[0],
                function ( $m, $str ) use ( $patternMatch1 ) {
                    $found = preg_match(
                        "/([\"'])(?:(?=(\\\\?))\\2.)*?\\1/u",
                        $str,
                        $matches
                    ); //matches first passed argument only
                    $m[]   = $found ? trim( $matches[0], '"\'' ) : $patternMatch1[1];

                    return $m;
                },
                array()
            );
        }
        if ( ! empty( $patternMatch2[1] )) {
            $strings = array_merge( $strings, $patternMatch2[1] );

            return $strings;
        }

        return $strings;
    }