Parse vector

@param string $vector

@return array
511911
static function parseVector($vector)
    {
        $vectorInputs = array();
        $vector = preg_replace('/^' . self::$vectorHead . '[\\' . self::$metricSeparator . ']?/', '', $vector);
        $metrics = explode(self::$metricSeparator, $vector);
        if (count($metrics)) {
            foreach ($metrics as $metric) {
                if (!empty($metric)) {
                    list($name, $value) = explode(self::$valueSeparator, $metric);
                    $vectorInputs[$name] = $value;
                }
            }
        }
        return $vectorInputs;
    }
562016
public function parse(string $string)
    {
        $array = [];

        foreach ($this->splitItems($string) as $item) {
            $array[] = $this->splitItem($item);
        }

        return $array;
    }
686965
private function parse($pointer)
    {
        if (!is_string($pointer)) {
            throw InvalidPointerException::invalidType(gettype($pointer));
        }

        if (!isset($pointer[0])) {
            return [];
        }

        // If the pointer is a url fragment, it needs to be url decoded.
        if ($pointer[0] === '#') {
            $pointer = urldecode(substr($pointer, 1));
        }

        // For convenience add the beginning slash if it's missing.
        if (isset($pointer[0]) && $pointer[0] !== '/') {
            $pointer = '/' . $pointer;
        }

        $pointer = array_slice(explode('/', $pointer), 1);
        return str_replace(['~1', '~0'], ['/', '~'], $pointer);
    }
1154326
protected function parseArray(string $values): array
    {
        $parsed = empty($values) === false ? explode(' ', $values) : [];

        return $parsed;
    }
817028
private function parseStringToArray($string)
    {
        // convert commas to spaces
        $string = str_replace(',', ' ', $string);
        // convert new lines to spaces
        $string = str_replace(PHP_EOL, ' ', $string);
        // split on the spaces and filter out empty elements
        return array_values(
            array_filter(
                array_map(
                    'trim',
                    explode(' ', $string)
                ),
                'strlen'
            )
        );
    }
772179
public function parseAttributes($string)
    {
        $result = array();

        if (!empty($string))
        {
            $pattern = '#(?(DEFINE)
                (?<name>[a-zA-Z][a-zA-Z0-9-_:]*)
                (?<value_double>"[^"]+")
                (?<value_none>[^\s>]+)
                (?<value>((?&value_double)|(?&value_none)))
            )
            (?<n>(?&name))[\s]*(=[\s]*(?<v>(?&value)))?#xs';

            if (preg_match_all($pattern, $string, $matches, PREG_SET_ORDER))
            {
                foreach ($matches as $match) {
                    if (!empty($match['n'])) {
                        $result[$match['n']] = isset($match['v']) ? trim($match['v'], '\'"') : '';
                    }
                }
            }
        }

        return $result;
    }
711252
private function parseExpression($expression)
    {
        // Check for URI operators
        $operator = '';

        if (isset(self::$operatorHash[$expression[0]])) {
            $operator = $expression[0];
            $expression = substr($expression, 1);
        }

        $values = explode(',', $expression);
        foreach ($values as &$value) {
            $value = trim($value);
            $varspec = array();
            $substrPos = strpos($value, ':');
            if ($substrPos) {
                $varspec['value'] = substr($value, 0, $substrPos);
                $varspec['modifier'] = ':';
                $varspec['position'] = (int) substr($value, $substrPos + 1);
            } elseif (substr($value, -1) == '*') {
                $varspec['modifier'] = '*';
                $varspec['value'] = substr($value, 0, -1);
            } else {
                $varspec['value'] = (string) $value;
                $varspec['modifier'] = '';
            }
            $value = $varspec;
        }

        return array(
            'operator' => $operator,
            'values'   => $values
        );
    }
268520
public static function parse($expression)
    {
        $name = static::name($expression);

        if (preg_match_all('/\{\s*(.*?)\s*\}/', $expression, $matches)) {
            if (count($matches[1])) {
                return array_merge([$name], static::parameters($matches[1]));
            }
        }

        return [$name, [], []];
    }
744618
protected function parseLine($line)
    {
        $split = preg_split('/\s/', $line, 2);

        return array(
            'key' => $split[0],
            'value' => isset($split[1]) ? $split[1] : null
        );
    }
631804
public static function parse($string)
  {
    $attr = [];
    $list = [];

    preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);

    if ( is_array($attr) ){
      $numPairs = count($attr[1]);
      for ($i = 0; $i < $numPairs; $i++){
        $list[$attr[1][$i]] = $attr[2][$i];
      }
    }
    
    return $list;
  }
779085
public function parse() : array
    {
        $fileLines = $this->getFileLines();

        $data = [];

        $currentSection  = '';
        $currentDivision = '';

        for ($line = 0, $count = count($fileLines); $line < $count; ++$line) {
            $currentLine       = ($fileLines[$line]);
            $currentLineLength = mb_strlen($currentLine);

            if (0 === $currentLineLength) {
                continue;
            }

            if (';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;' === mb_substr($currentLine, 0, 40)) {
                $currentDivision = trim(mb_substr($currentLine, 41));

                continue;
            }

            // We only skip comments that *start* with semicolon
            if (';' === $currentLine[0]) {
                continue;
            }

            if ('[' === $currentLine[0]) {
                $currentSection = mb_substr($currentLine, 1, ($currentLineLength - 2));

                continue;
            }

            $bits = explode('=', $currentLine);

            if (2 < count($bits)) {
                throw new \RuntimeException("Too many equals in line: {$currentLine}, in Division: {$currentDivision}");
            }

            if (2 > count($bits)) {
                $bits[1] = '';
            }

            $data[$currentSection][$bits[0]]   = $bits[1];
            $data[$currentSection]['Division'] = $currentDivision;
        }

        if ($this->shouldSort()) {
            $data = $this->sortArrayAndChildArrays($data);
        }

        $this->data = $data;

        return $data;
    }
1320725
public static function parse_headers(string $headers): array
    {
        $final_headers = array();
        $list = explode("\n", trim($headers));

        $http = array_shift($list);

        foreach ($list as $header) {
            $parts = explode(':', $header, 2);
            $final_headers[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
        }

        return $final_headers;
    }
355804
public function parse($payload)
    {
        if ($payload) {
            try {
                $xml = simplexml_load_string($payload, 'SimpleXMLElement', (LIBXML_VERSION >= 20700) ? (LIBXML_PARSEHUGE | LIBXML_NOCDATA) : LIBXML_NOCDATA);
                $ns = ['' => null] + $xml->getDocNamespaces(true);
                return $this->recursive_parse($xml, $ns);
            } catch (\Exception $ex) {
                throw new ParserException('Failed To Parse XML');
            }
        }

        return [];
    }
615480
protected function parseQueryPair(string $data): array
    {
        $data = explode('=', $data, 2);
        if (1 === count($data)) {
            $data[] = '';
        }

        return array_map(__NAMESPACE__ . '\decode', $data);
    }
803148
public function findAll(string $needle) : array
    {
        $lastPos = 0;
        $positions = [];
        $needle = strtolower($needle);
        $text = strtolower($this->getText());
        $needleLength = strlen($needle);
        while (($lastPos = stripos($text, $needle, $lastPos))!== false)
        {
            $positions[] = $lastPos;
            $lastPos += $needleLength;
        }
        return $positions;
    }
851106
public function parse($url) {
		// iterate all rules
		$hit = false;

		foreach ($this->_routes as $rule => $new_class) {
			$regex		= trim($rule, '/');

			// rebuild route to a preg pattern
			if (preg_match($regex, $url, $parameters)) {
				$class = preg_replace($regex, $new_class, $url);
				$class = str_replace('/', '_', $class);
				unset($parameters[0]);
				$hit = true;
				break;
			}
		}

		if ($hit === false) {
			$class = call_user_func($this->_fallback, $url);
		}

		$class_shards = explode('\\', $class);
		$class_shards[count($class_shards)-1] = ucfirst(strtolower($class_shards[count($class_shards)-1]));
		$class = implode('\\', $class_shards);

		return [
			'controller'		=> $class,
			'parameters'		=> isset($parameters) ? $parameters : [],
		];
	}
947551
private static function parseArray($val)
    {
        $result = array();
        $openBrackets = 0;
        $openString = false;
        $openLString = false;
        $buffer = '';

        $strLen = strlen($val);
        for($i = 0; $i < $strLen; $i++)
        {
            if($val[$i] == '[' && !$openString && !$openLString)
            {
                $openBrackets++;

                if($openBrackets == 1)
                {
                    // Skip first and last brackets.
                    continue;
                }
            }
            elseif($val[$i] == ']' && !$openString && !$openLString)
            {
                $openBrackets--;

                if($openBrackets == 0)
                {
                    // Allow terminating commas before the closing bracket
                    if(trim($buffer) != '')
                    {
                        $result[] = self::parseValue( trim($buffer) );
                    }

                    if (!self::checkDataType($result))
                    {
                        throw new Exception('Data types cannot be mixed in an array: ' . $buffer);
                    }
                    // Skip first and last brackets. We're finish.
                    return $result;
                }
            }
            elseif($val[$i] == '"' && $val[$i - 1] != "\\" && !$openLString)
            {
                $openString = !$openString;
            }
            elseif($val[$i] == "'"  && !$openString) {
                $openLString = !$openLString;
            }

            if( $val[$i] == ',' && !$openString && !$openLString && $openBrackets == 1)
            {
                $result[] = self::parseValue( trim($buffer) );

                if (!self::checkDataType($result))
                {
                    throw new Exception('Data types cannot be mixed in an array: ' . $buffer);
                }
                $buffer = '';
            }
            else
            {
                $buffer .= $val[$i];
            }
        }

        // If we're here, something went wrong.
        throw new Exception('Wrong array definition: ' . $val);
    }