Parses a cookie JAR line.

@param  string    $line The cookie JAR line.
@return array           The data array.
@throws Exception       It throws an exception the cookie JAR line is invalid.
8025
public static function parse($line)
    {
        $parts = explode("\t", trim($line));

        if (count($parts) !== 7) {
            throw new RuntimeException("Invalid cookie JAR format.");
        }

        $config = [];
        $config['httponly'] = '#HttpOnly_' === substr($parts[0], 0, 10);
        $config['domain'] = $config['httponly'] ? substr($parts[0], 10) : $parts[0];
        $config['path'] = $parts[2];
        $config['secure'] = ($parts[3] === 'TRUE') ? true : false;
        $config['expires'] = (integer) $parts[4];
        $config['name'] = $parts[5];
        $config['value'] = $parts[6];

        return $config;
    }
612109
protected function processContinuedLineInSameState($line)
    {
        switch ($this->state) {
            case 'msgctxt':
            case 'msgid':
            case 'msgid_plural':
                if (is_string($this->currentEntry[$this->state])) {
                    // Convert it to array
                    $this->currentEntry[$this->state] = array($this->currentEntry[$this->state]);
                }
                $this->currentEntry[$this->state][] = $line;
                break;
            case 'msgstr':
                $this->currentEntry['msgstr'][] = trim($line, '"');
                break;
            default:
                throw new \Exception('Parse error!');
        }
    }
382794
public static function fromLine($line, array $lineOptions)
    {
        $line = \json_decode($line, true);
        $method = Inflector::camelize($line['type']) . 'FromLine';
        if (\method_exists(\get_class(new static()), $method) && $method !== 'FromLine') {
            return static::$method($line, $lineOptions);
        }

        throw new \Exception('Unknown message type: ' . $line['type']);
    }
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;
    }
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)];
    }
709269
public static function createFromString($Line)
    {
        // explode the string into lines.
        $lines = explode("\n", $Line);

        // extract the method and uri
        list( $method, $uri ) = explode(' ', array_shift($lines));

        $headers = [];

        foreach ($lines as $line) {
            // clean the line
            $line = trim($line);

            if (strpos($line, ': ') !== false) {
                list( $key, $value ) = explode(': ', $line);
                $headers[$key] = $value;
            }
        }
        
        $reqBody = new \Sofi\HTTP\RequestBody();
        $headers = \Sofi\HTTP\Headers::createFromArray($headers);
        $cookies = \Sofi\HTTP\Cookies::parseHeader($headers->get('cookie'));
        
        return new static($method, new \Sofi\HTTP\message\Uri($uri), $headers, $cookies, $_SERVER, $reqBody);
    }
1286418
public function parse($lines)
    {
        $data = [];
        foreach ($lines as $line) {
            if ($line === '' || $line[0] === '#') {
                continue;
            }

            if ($pos = strpos($line, ' # ')) {
                $line = substr($line, 0, $pos);
            }
            $line = trim($line);
            if (strpos($line, 'export ') === 0) {
                $parts = explode('=', ltrim(substr($line, 7)), 2);
            } else {
                $parts = explode('=', $line, 2);
            }

            if (count($parts) !== 2) {
                throw new InvalidValueException(['invalid line: :line, has no = character', 'line' => $line]);
            }
            $name = $parts[0];
            $value = $parts[1];

            if ($value === '') {
                null;
            } elseif ($value === 'true') {
                $value = true;
            } elseif ($value === 'false') {
                $value = false;
            } elseif ($value === 'null') {
                $value = null;
            } else {
                $fc = $value[0];
                if (($fc === '"' || $fc === "'") && $value[strlen($value) - 1] === $fc) {
                    $value = substr($value, 1, -1);
                    $value = strtr($value, ["\\$fc" => $fc]);
                }
                $value = strtr($value, ['\n' => PHP_EOL]);

                if (strpos($value, '${') !== false) {
                    preg_match_all('#\$\{([\w\.]+)\}#', $value, $matches, PREG_PATTERN_ORDER);
                    foreach ((array)$matches[1] as $match) {
                        $ref_name = $match;
                        if (!isset($data[$ref_name])) {
                            throw new InvalidValueException('`:ref` ref variable is not exists: :value', ['ref' => $ref_name, 'value' => $value]);
                        }
                        $value = strtr($value, ['${' . $ref_name . '}' => $data[$ref_name]]);
                    }
                } elseif (strpos($value, '$') !== false) {
                    preg_match_all('#\$([A-Z_\d]+)#', $value, $matches, PREG_PATTERN_ORDER);
                    foreach ((array)$matches[1] as $match) {
                        $ref_name = $match;
                        if (!isset($data[$ref_name])) {
                            throw new InvalidValueException(['`:ref` ref variable is not exists: :value', 'ref' => $ref_name, 'value' => $value]);
                        }
                        $value = strtr($value, ['$' . $ref_name => $data[$ref_name]]);
                    }
                }
            }

            $data[$name] = $value;
        }

        return $data;
    }
199814
protected function validateRequestLine($line)
    {
        $matches = [0 => null, 1 => null];

        if (!preg_match(self::REQUEST_LINE_REGEX, $line, $matches) || !$matches[1]) {
            throw new BadRequestException('Invalid request line', 400);
        }

        return $matches[1];
    }
1164329
private function getLinesNumbers(string $line)
    {
        $matches = [];
        preg_match('/@@ -(.*) \+(.*) @@?(.*)/', $line, $matches);
        if (!strpos($matches[1], ',')) {
            // one line
            $this->originStartLine = $matches[1];
            $this->originEndLine = $matches[1];
        } else {
            list($this->originStartLine, $this->originEndLine) = explode(',', $matches[1]);
        }

        if (!strpos($matches[2], ',')) {
            // one line
            $this->destStartLine = $matches[2];
            $this->destEndLine = $matches[2];
        } else {
            list($this->destStartLine, $this->destEndLine) = explode(',', $matches[2]);
        }
    }
1239355
public function parseLine($line) {

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

        $model = new User();
        $model->setUserNumber(IntegerHelper::parseString($data[++$i]));
        $model->setCustomerNumber(IntegerHelper::parseString($data[++$i]));
        $model->setTitle($this->decodeString($data[++$i]));
        $model->setSurname($this->decodeString($data[++$i]));
        $model->setFirstname($this->decodeString($data[++$i]));
        $model->setDateBirth($this->decodeDate($data[++$i]));
        $model->setParkingSpace($this->decodeString($data[++$i]));
        $model->setRemarks($this->decodeString($data[++$i]));
        $model->setDatetimeLastModification($this->decodeDateTime($data[++$i]));
        $model->setDeletedRecord(BooleanHelper::parseString($data[++$i]));
        $model->setIdentificationNumber($this->decodeString($data[++$i]));
        $model->setCheckLicensePlate(BooleanHelper::parseString($data[++$i]));
        $model->setPassageLicensePlatePermitted(BooleanHelper::parseString($data[++$i]));
        $model->setExcessTimesCreditCard(BooleanHelper::parseString($data[++$i]));
        $model->setCreditCardNumber($this->decodeString($data[++$i]));
        $model->setExpiryDate($this->decodeDate($data[++$i]));
        $model->setRemarks2($this->decodeString($data[++$i]));
        $model->setRemarks3($this->decodeString($data[++$i]));
        $model->setDivision($this->decodeString($data[++$i]));
        $model->setEmail($this->decodeString($data[++$i]));
        $model->setGroupCounting(BooleanHelper::parseString($data[++$i]));
        $model->setETicketTypeP(IntegerHelper::parseString($data[++$i]));
        $model->setETicketEmailTelephone($this->decodeString($data[++$i]));
        $model->setETicketAuthentication(IntegerHelper::parseString($data[++$i]));
        $model->setETicketServiceTyp(IntegerHelper::parseString($data[++$i]));
        $model->setETicketServiceArt(IntegerHelper::parseString($data[++$i]));

        return $model;
    }
1232206
public function parseName($line)
    {
        $matches = [];
        $pattern = '/^\*\s+remote\s+(.*)$/';
        preg_match($pattern, trim($line), $matches);
        if (!isset($matches[1])) {
            return '';
        }

        return $matches[1];
    }
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);
    }
1029826
protected function parse_line($line)
    {
        $line = trim($line);
        if (empty($line)) {
            return null;
        }

        $fields = rcube_utils::explode_quoted_string(',', $line);

        // remove quotes if needed
        if (!empty($fields)) {
            foreach ($fields as $idx => $value) {
                if (($len = strlen($value)) > 1 && $value[0] == '"' && $value[$len-1] == '"') {
                    // remove surrounding quotes
                    $value = substr($value, 1, -1);
                    // replace doubled quotes inside the string with single quote
                    $value = str_replace('""', '"', $value);

                    $fields[$idx] = $value;
                }
            }
        }

        return $fields;
    }
1259273
public function parse($line)
    {
        $object = new \stdClass();

        $object->type = 'info';
        $object->message = $line;

        return $object;
    }
1159253
private function processLine(string $line): void
    {
        $iterator = new \ArrayIterator(explode(Tokens::SPACE, $line));

        if ($this->isControlEntry($iterator)) {
            $this->processControlEntry($iterator);

            return;
        }

        $resourceRecord = new ResourceRecord();

        $this->processResourceName($iterator, $resourceRecord);
        $this->processTtl($iterator, $resourceRecord);
        $this->processClass($iterator, $resourceRecord);
        $resourceRecord->setRdata($this->extractRdata($iterator));

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

        return $_result;
    }
132544
protected function parseTag($line)
    {
        $tagAndValue = preg_split('/\\s/', $line, 2);
        $tag = substr($tagAndValue[0], 1);
        if (count($tagAndValue) > 1) {
            $this->tags[$tag][] = trim($tagAndValue[1]);
        } else {
            $this->tags[$tag] = [];
        }
    }