Parse the any nested key-pair values in the header value

@param  string $nestedPairs
@return array
4121
protected function parseNestedKeyPairHeader($nestedPairs)
    {
        return array_reduce(explode(';', $nestedPairs), function($result, $pair) {
            $keyVal = explode('=', $pair, 2);
            $key = trim(array_shift($keyVal));
            $val = trim(implode('=', $keyVal));
            if ($key !== '' && $val !== '') {
                $result[$key] = $val;
            }
            return $result;
        }, []);
    }
41887
public function whereSplit($items, $keyValuePairs)
    {
        return array(
            $this->notWhere($items, $keyValuePairs),
            $this->where($items, $keyValuePairs)
        );
    }
86410
private function parseTokens(array $tokens)
    {
        return array_map(function ($token, $key) {
            return ['name' => $key, 'value' => $token];
        }, $tokens, array_keys($tokens));
    }
444265
public function normalizeHeaders(array $headers):array {
		$normalized_headers = [];

		foreach($headers as $key => $val){

			if(is_numeric($key)){
				$header = explode(':', $val, 2);

				if(count($header) === 2){
					$key = $header[0];
					$val = $header[1];
				}
				else{
					continue;
				}
			}

			$key = ucfirst(strtolower($key));

			$normalized_headers[$key] = trim($key).': '.trim($val);
		}

		return $normalized_headers;
	}
324574
protected function parseAcceptHeader(?string $headerValue): array
	{
		$groupedAccepts = [];

		if(empty($headerValue))
		{
			return $groupedAccepts;
		}

		// Collect acceptable values

		foreach(explode(',', $headerValue) as $accept)
		{
			$quality = 1;

			if(strpos($accept, ';'))
			{
				// We have a quality so we need to split some more

				[$accept, $quality] = explode(';', $accept, 2);

				// Strip the "q=" part so that we're left with only the numeric value

				$quality = substr(trim($quality), 2);
			}

			$groupedAccepts[$quality][] = trim($accept);
		}

		// Sort in descending order of preference

		krsort($groupedAccepts);

		// Flatten array and return it

		return array_merge(...array_values($groupedAccepts));
	}
805486
protected function parseHeaders(array $headers)
	{
		$this->headers = array();

		// find and set the HTTP status code and reason
		$firstHeader = array_shift($headers);
		if (!preg_match('/^HTTP\/\d(\.\d)? [0-9]{3}/', $firstHeader)) {
			throw new \InvalidArgumentException('Invalid response header');
		}
		list(, $status) = explode(' ', $firstHeader, 2);
		$code = explode(' ', $status);
		$code = (int) $code[0];

		// special handling for HTTP 100 responses
		if ($code === 100) {
			// remove empty header lines between 100 and actual HTTP status
			foreach ($headers as $key => $header) {
				if ($header) {
					break;
				}
				unset($headers[$key]);
			}

			// start the process over with the 100 continue header stripped away
			return $this->parseHeaders($headers);
		}

		$this->statusText = $status;
		$this->statusCode = $code;

		foreach ($headers as $header) {
			// skip empty lines
			if (!$header) {
				continue;
			}

			$delimiter = strpos($header, ':');
			if (!$delimiter) {
				continue;
			}

			$key = trim(strtolower(substr($header, 0, $delimiter)));
			$val = ltrim(substr($header, $delimiter + 1));

			if (isset($this->headers[$key])) {
				if (is_array($this->headers[$key])) {
					$this->headers[$key][] = $val;
				} else {
					$this->headers[$key] = array($this->headers[$key], $val);
				}
			} else {
				$this->headers[$key] = $val;
			}
		}
	}
451356
public function parseHeaders(array $headers)
    {
        $parsed = [];

        foreach ($headers as $key => $val)
        {
            $parsed[] = $key . ': ' . $val;
        }

        return $parsed;
    }
740713
public static function parseHeaders(string $raw_header): array
    {
        $raw_header = explode("\r\n\r\n", $raw_header);
        if (count($raw_header) > 1) {
            $headers = [];
            foreach ($raw_header as $header) {
                $headers[] = self::parseHeader($header);
            }

            return $headers;
        } else {
            return self::parseHeader($raw_header[0]);
        }
    }
321715
protected function flattenTranslations(array $nestedMessages, $keyPrefix='')
    {
        $flattened = [];

        foreach ($nestedMessages as $key => $message) {
            if (is_array($message)) {
                $flattenedMessages = $this->flattenTranslations($message, $keyPrefix . $key . '.');
                $flattened = array_merge($flattened, $flattenedMessages);
            } else {
                $flattened[$keyPrefix.$key] = $message;
            }
        }

        return $flattened;
    }
205952
public function readHeader($arrHeaders)
    {
        $headers = [];
        if (is_array($arrHeaders)) {
            foreach($arrHeaders as $h) {
                $rs = preg_split('/:/', $h);
                if (count($rs)==2) {
                    $headers[$rs[0]] = trim($rs[1]);
                }
            }
        }
        return $headers;
    }
245463
private function parseHeaders(array $headers)
    {

        // Set the raw headers as we got from the constructor.
        $this->raw_headers = $headers;

        // flatten the headers array so that values are not arrays themselves
        // but rather simple key value pairs.
        $headers = array_map(function ($value) {

            if (! is_array($value))
                return $value;

            return implode(';', $value);
        }, $headers);

        // Set the parsed headers.
        $this->headers = $headers;

        // Check for some header values that might be interesting
        // such as the current error limit and number of pages
        // available.
        $this->hasHeader('X-Esi-Error-Limit-Remain') ?
            $this->error_limit = (int) $this->getHeader('X-Esi-Error-Limit-Remain') : null;

        $this->hasHeader('X-Pages') ? $this->pages = (int) $this->getHeader('X-Pages') : null;
    }
698081
public function decodePair(string $keyValuePair): array
    {
        # more than a handful of clients like to use '+' characters
        # when encoding data that is (almost) compliant with rfc 3986
        # this is a hack that allows for it
        if (strpos($keyValuePair, "+") !== false) {
            $keyValuePair = str_replace("+", " ", $keyValuePair);
        }

        $parts = explode("=", $keyValuePair, 2);
        $key = rawurldecode($parts[0]);

        # interpret a key with an empty value as `null`
        $value = (count($parts) === 1) ? null : rawurldecode($parts[1]);
        return [$key, $value];
    }
305022
protected function parseRelationships($includedData)
    {
        $relationships = [];

        foreach ($includedData as $key => $inclusion) {
            foreach ($inclusion as $includeKey => $includeObject) {
                $relationships = $this->buildRelationships($includeKey, $relationships, $includeObject, $key);
                if (isset($includedData[0][$includeKey]['meta'])) {
                    $relationships[$includeKey][0]['meta'] = $includedData[0][$includeKey]['meta'];
                }
            }
        }

        return $relationships;
    }
554696
protected static function parseOrders(array $rawOrders) {

        $dtOrders = [];

        foreach ($rawOrders as $current) {
            $dtOrders[] = static::parseOrder($current);
        }

        return $dtOrders;
    }
196380
protected function resolveNestedRelations($data):array
    {
        if (is_null($data)) {
            return [];
        }

        $data = $data instanceof Model ? [$data] : $data;

        return collect($data)->flatMap(function ($model) {
            $relations = collect($model->getRelations());

            return $relations->keys()->merge($relations->flatMap(function ($relation, $key) {
                return collect($this->resolveNestedRelations($relation))->map(function ($nestedRelation) use ($key) {
                    return $key . '.' . $nestedRelation;
                });
            }));
        })->unique()->toArray();
    }
64462
protected function getFinalEntityMapper(array $nestedRelations) : IEntityMapper
    {
        $entityMapper = null;

        foreach (array_reverse($nestedRelations) as $relation) {
            if ($relation instanceof EntityRelation) {
                $entityMapper = $relation->getEntityMapper();
                break;
            }
        }

        return $entityMapper ?: $this->rootEntityMapper;
    }
188557
protected function _parseHeaders($headers)
    {
        foreach ($headers as $key => $value) {
            if (substr($value, 0, 5) === 'HTTP/') {
                preg_match('/HTTP\/([\d.]+) ([0-9]+)(.*)/i', $value, $matches);
                $this->protocol = $matches[1];
                $this->code = (int)$matches[2];
                $this->reasonPhrase = trim($matches[3]);
                continue;
            }
            if (strpos($value, ':') === false) {
                continue;
            }
            list($name, $value) = explode(':', $value, 2);
            $value = trim($value);
            $name = trim($name);

            $normalized = strtolower($name);

            if (isset($this->headers[$name])) {
                $this->headers[$name][] = $value;
            } else {
                $this->headers[$name] = (array)$value;
                $this->headerNames[$normalized] = $name;
            }
        }
    }