Parses an array of header lines into an associative array of headers.

@param array $lines Header lines array of strings in the following
format: "Name: Value"
@return array
352251
public static function headersFromLines($lines)
    {
        $headers = [];

        foreach ($lines as $line) {
            $parts = explode(':', $line, 2);
            $headers[trim($parts[0])][] = isset($parts[1])
                ? trim($parts[1])
                : null;
        }

        return $headers;
    }
942309
private function parseCsv($line): array
    {
        return str_getcsv(
            $line,
            $this->conversion['delimiter'],
            $this->conversion['enclosure'],
            $this->conversion['escape']
        );
    }
947386
protected function parseAirlines(array $airlines)
    {
        $parsed = [];

        foreach ($airlines as $airline) {
            $parsed[$airline['fs']] = $airline;
        }

        return $parsed;
    }
379520
protected function mergeDuplicates(array $line)
    {
        $values = [];

        $i = 0;
        foreach ($this->columnHeaders as $count) {
            if (1 === $count) {
                $values[] = $line[$i];
            } else {
                $values[] = array_slice($line, $i, $count);
            }

            $i += $count;
        }

        return $values;
    }
779380
protected function addYamlFrontmatter($lines)
    {
        $text = implode("\n", $lines);
        $parsed = $this->parseYaml($text);

        if (!is_array($parsed)) {
            $parsed = [$parsed];
        }

        $this->frontmatter = array_merge($this->frontmatter, $parsed);
    }
620968
public function parse($line)
    {
        $elements = [];

        // 1. remove braces
        $line = \str_replace(['{', '}'], '', $line);

        // 2. extract elements
        $elements = $this->extractElements($line);

        // 3. remove quotes
        $iterator = function($element)
        {
            return \str_replace(['\'', '"'], '', $element);
        };

        return \array_map($iterator, $elements);
    }
961870
protected function parseHeaders($string) 
    {
        $headers = array();
        $lines = explode("\r\n", trim($string));
        foreach($lines as $line) {
            @list($key, $val) = explode(':', $line, 2);
            $key = strtolower(trim($key));
            $val = trim($val);
            if(empty($val)) continue;
            if(isset($headers[$key])) {
                if(is_array($headers[$key])) {
                    $headers[$key][] = $val;
                } else {
                    $headers[$key] = array($headers[$key], $val);
                }
            } else {
                $headers[$key] = $val;
            }
        }
        return $headers;
    }
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)
        );
    }
1367680
protected function unfold(array $lines)
    {
        $string = implode(PHP_EOL, $lines);
        $string = preg_replace('/' . PHP_EOL . '[ \t]/', '', $string);
        $lines  = explode(PHP_EOL, $string);

        return $lines;
    }
847401
public static function parse($line)
    {
        $data = explode(':', $line);
        $filed = $data[0];
        if (isset($data[2])) {
            unset($data[0]);
            $value = implode(':', $data);
        } else {
            $value = $data[1];
        }
        return [rtrim($filed), ltrim($value)];
    }
1235708
public function parseLocalPushRefs($lines)
    {
        $branches = [];
        $delimiter = ' pushes to ';
        foreach ($lines as $line) {
            $line = trim($line);
            $line = preg_replace('/\s+/', ' ', $line);
            $parts = explode($delimiter, $line);
            if (count($parts) > 1) {
                $value = explode(' ', $parts[1], 2);
                $branches[$parts[0]] = ['pushes_to' => $value[0], 'local_state' => $value[1]];
            }
        }

        return $branches;
    }
818563
public function parseHeader($header)
    {
        $parsed_header = array();

        $header_lines = explode("\r\n", $header);
        if (count($header_lines) > 0) {
            foreach ($header_lines as $line) {
                $header = explode(':', $line);
                if (count($header) > 1) {
                    $label = array_shift($header);

                    $value = $header;
                    $value = implode(':', $header);
                    $value = trim($value);

                    $parsed_header[$label] = $value;
                }
            }
        }

        return $parsed_header;
    }
1233703
private function parseMh(array $lines, $num, $start, $end)
    {
        return $this->parseSh($lines, $num, $start, $end);
    }
761202
public function setLines(array $lines)
    {
        $translator = $this->factory->getTranslator();

        if ($translator instanceof Translator) {
            $translator->setLines($lines);
        }
    }
91735
public function setLines($lines)
    {
        if (!is_array($lines)) {
            $this->lines = array(
                $lines
            );
        } else {
            $this->lines = $lines;
        }

        return $this;
    }
781316
protected function completeInvoiceLines(array $lines)
    {
        $lines = $this->addVatRateTo0PriceLines($lines);
        $lines = $this->recalculateLineData($lines);
        $lines = $this->completeLineMetaData($lines);
        return $lines;
    }
947758
def parse_headers(lines, offset=0):
    
    headers = {}
    for header_line in lines[offset:]:
        header_match = HEADER_LINE_RE.match(header_line)
        if header_match:
            key = header_match.group('key')
            key = re.sub(r'\\.', _unescape_header, key)
            if key not in headers:
                value = header_match.group('value')
                value = re.sub(r'\\.', _unescape_header, value)
                headers[key] = value
    return headers