@param $lines

@return array
357500
private function buildComponents(array &$lines)
    {
        $componentsByType = [];

        /** @var $component Component */
        foreach ($this->components as $component) {
            $type = $component->getType();
            if (!isset($componentsByType[$type])) {
                $componentsByType[$type] = [];
            }
            $componentsByType[$type][] = $component;
        }

        // render ordered components
        foreach ($this->componentsBuildOrder as $type) {
            if (!isset($componentsByType[$type])) {
                continue;
            }
            foreach ($componentsByType[$type] as $component) {
                $this->addComponentLines($lines, $component);
            }
            unset($componentsByType[$type]);
        }

        // render all other
        foreach ($componentsByType as $components) {
            foreach ($components as $component) {
                $this->addComponentLines($lines, $component);
            }
        }
    }
387980
public function getMaxLineLength($lines)
    {
        if (!is_array($lines)) {
            $lines = explode("\n", $lines);
        }
        $lineLength = 0;
        // find the longest line
        foreach ($lines as $line) {
            $currentLineLength = strlen($line);
            if ($currentLineLength > $lineLength) {
                $lineLength = $currentLineLength;
            }
        }
        return $lineLength;
    }
784943
protected function formatLines(array $lines, $type = 'return')
    {
        $template = \sprintf('<%s>%%s</%s>', $type, $type);

        return \array_map(function ($line) use ($template) {
            return \sprintf($template, $line);
        }, $lines);
    }
515178
public function delete($line, $lines)
    {
        foreach (range(0, $lines-1) as $offset) {
            $this->lines[$line+$offset-1] = null;
        }
        return $this;
    }
379055
protected function extractElements($line)
    {
        $elements = [];
        $buffer   = '';
        $quote    = false;

        foreach (\str_split($line) as $character)
        {
            if (\in_array($character, ['\'', '"']))
            {
                $quote = ! $quote;

                continue;
            }

            if ((':' == $character) and ! $quote)
            {
                $elements[] = $buffer;

                $buffer = '';

                continue;
            }

            $buffer .= $character;
        }

        if ($buffer)
        {
            $elements[] = $buffer;
        }

        return $elements;
    }
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;
    }
1056848
protected function parseEncoder($lines) {
    $encoders = array();
    foreach ($lines as $line) {
      if (preg_match('/^\s+([A-Z .]+)\s+(\w{2,})\s+(.*)$/', $line, $m)) {
        $type = trim($m[1]);
        if (strpos($type, 'E') !== false) {
          $encoder = trim($m[2]);
          if (strpos($encoder, ',') !== false) {
            foreach (split(',', $encoder) as $e) {
              $encoders[] = $e;
            }
          } else {
            $encoders[] = $encoder;
          }
        }
      }
    }

    sort($encoders);
    return $encoders;
  }
84526
private function getIndent(array $lines)
    {
        $detector = new IndentationDetector(
            LineCollection::createFromArray($lines)
        );

        return str_repeat(' ', $detector->getFirstLineIndentation());
    }
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;
    }
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;
    }
173888
public function getLastLines(int $numberOfLines = self::DEFAULT_NUMBER_OF_LINES): array
    {
        $lines = [];
        if (null === $this->file) {
            return $lines;
        }

        $this->file->seek($this->lineCount);
        $currentKey = $this->file->key();
        while ($currentKey >= 0) {
            $line = $this->getDefaultParser()->parse($this->file->current());
            if ($line) {
                $lines[] = $line;
            }

            if (--$currentKey >= 0) {
                $this->file->seek($currentKey);
            }

            if (\count($lines) >= $numberOfLines) {
                break;
            }
        }

        return $lines;
    }
109255
public function getLines()
    {
        $lines = explode(PHP_EOL, $this->comment);

        $wrapper = function($line)
        {
            return new Line($line);
        };

        return array_map($wrapper, $lines);
    }
69357
public function parse($line)
    {
        $object = new \stdClass();
        $matches = [];

        foreach ($this->getPatterns() as $key => $pattern) {
            $result = preg_match($pattern, $line, $matches);

            if (1 !== $result) {
                continue;
            }

            $object->$key = $matches[1];
        }

        if (false === property_exists($object, 'date')) {
            throw new FormatException;
        }

        if (false === property_exists($object, 'type')) {
            throw new FormatException;
        }

        return $object;
    }
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);
    }
980592
protected function parseInfo($lines) {
    $result = array('videoStreams' => 0, 'audioStreams' => 0);
    foreach ($lines as $line) {
      if (preg_match('/Duration:\s+(\d\d):(\d\d):(\d\d\.\d+)/', $line, $m)) {
        $result['duration'] = $m[1] * 3600 + $m[2] * 60 + $m[3];
      } else if (preg_match('/\s+Stream #(\d)+.*$/', $line, $sm)) {
        if (strpos($line, 'Video:')) {
          $result['videoStreams']++;
          $words = preg_split('/,?\s+/', trim($line));
          for ($i = 0; $i < count($words); $i++) {
            if (preg_match('/(\d+)x(\d+)/', $words[$i], $m)) {
              $result['width'] = $m[1];
              $result['height'] = $m[2];
            }
          }
        } else if (strpos($line, 'Audio:')) {
          $result['audioStreams']++;
        }
      }
    }
    return $result;
  }
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;
    }
772289
protected function parseLine( $line )
	{
		$data	= preg_replace_callback( $this->patterns, array( $this, 'callback' ), $line );
		return unserialize( $data );
	}