Get array of headers from header bag

@param HeaderBag $headerBag
@return array
351588
private static function prepareHeaders(HeaderBag $headerBag)
    {
        $headers = $headerBag->all();
        $result = [];

        foreach ($headers as $header => $values) {
            $result[$header] = $values[0];
        }

        return $result;
    }
5435
public static function getFromCache(RequestBag $requestBag)
    {
        // check if we have cache in settings
        if (!$requestBag->getApiConfig()->get('Cache', false) || $requestBag->getMethodData()['cache']['ttl'] <= 0) {
            return false;
        }

        $instance = new self($requestBag);

        return $instance->getCallbackResultFromCache();
    }
1218141
public function headers(): array
    {
        return collect($this->request->getHeaders())->mapWithKeys(function ($values, $header) {
            return [$header => $values[0]];
        })->all();
    }
976465
public static function parseHeaders($headerString)
	{
		$headers = explode("\n", $headerString);
		$keys = array_keys($headers);
		$regexReturnCode = '/^\S+\s+(\d+)\s?(.*)/';
		$regexHeader = '/^(.*?):\s*(.*)$/';
		$headers['Return-Code'] = preg_match($regexReturnCode, $headerString, $matches)
			? $matches[1]
			: 200;
		foreach ($keys as $k) {
			$v = trim($headers[$k]);
			unset($headers[$k]);
			if (preg_match($regexHeader, $v, $matches)) {
				$k = $matches[1];
				$k = preg_replace_callback('/(^|-)(.?)/', function ($matches) {
					return $matches[1].strtoupper($matches[2]);
				}, $k);
				$v = trim($matches[2]);
				if (isset($headers[$k])) {
					if (!is_array($headers[$k])) {
						$headers[$k] = array($headers[$k]);
					}
					$headers[$k][] = $v;
				} else {
					$headers[$k] = $v;
				}
			} elseif (preg_match($regexReturnCode, $v, $matches)) {
				$headers['Return-Code'] = $matches[1];
			}
		}
		return $headers;
	}
665538
private function parseHeaders($headers)
    {
        $result = [];

        foreach (preg_split("/\\r\\n|\\r|\\n/", $headers) as $row) {
            $header = explode(':', $row, 2);

            if (count($header) == 2) {
                $result[$header[0]] = trim($header[1]);
            }
            else {
                $result[] = $header[0];
            }
        }

        return $result;
    }
928588
public function extractHeaders()
    {
        $headers = [];
        foreach (array_keys($this->cors) as $headerField) {
            $headerData = $this->request->getHeaderLine($headerField);
            if ($headerData !== null) {
                $headers[$headerField] = $headerData;
            }
        }

        return $headers;
    }
1098765
public function sendHeader($statusCode = 200, $headerBag = null)
    {
        if ($this->response->header !== null) {
            // If any headers has been set in response, we will consider the
            // response headers has been sent.
            return;
        }

        $this->response->status($statusCode);

        $headerBag = $headerBag ?? new ResponseHeaderBag;

        // RFC2616 - 14.18
        // Origin servers MUST include a Date header field in all responses.
        $this->addDateHeaderIfNecessary($statusCode, $headerBag);

        foreach ($headerBag->allPreserveCaseWithoutCookies() as $name => $values) {
            $this->setHeaderInResponse($name, (array) $values);
        }

        foreach ($headerBag->getCookies() as $cookie) {
            $this->setCookieInResponse($cookie);
        }
    }
738267
public function sendHeaders(HeaderBag $headers)
    {
        # First, remove all headers on the response object
        $headersToRemove = $this->response->getHeaders();
        foreach ($headersToRemove as $name => $headerLines)
        {
            $this->response = $this->response->withoutHeader($name);
        }

        # And then, reset all headers from the HeaderBag instance
        foreach ($headers->get() as $header)
        {
            $this->response = $this->response->withAddedHeader(
                $header->getName(),
                $header->getValue()
            );
        }
    }
72050
private static function normalizeHeaders(array $headers): array
    {
        $normalizedHeaders = [];

        foreach ($headers as $name => $values) {
            if (\is_int($name)) {
                [$name, $values] = explode(':', $values, 2);
                $values = [ltrim($values)];
            } elseif (!\is_iterable($values)) {
                $values = (array) $values;
            }

            $normalizedHeaders[$name = strtolower($name)] = [];

            foreach ($values as $value) {
                $normalizedHeaders[$name][] = $value;
            }
        }

        return $normalizedHeaders;
    }
211999
public function getByName($name)
    {
        Types::assert(['string' => [$name]]);

        $name = strtolower($name);

        if ( ! array_key_exists($name, $this->headers))
        {
            return [];
        }

        return $this->headers[$name];
    }
640523
public function getHeader($name)
    {
        $headerSet = $this->getSwiftMessage()->getHeaders();
        if (!$headerSet->has($name)) {
            return [];
        }

        $headers = [];
        foreach ($headerSet->getAll($name) as $header) {
            $headers[] = $header->getValue();
        }
        return $headers;
    }
1075431
protected function normalizeHeaders(array $headers) : array
    {
        $returnHeaders = [];
        foreach ($headers as $key => $header) {
            $returnHeaders[$key] = $header[0] ?? $header;
        }

        return $returnHeaders;
    }
846570
final public function findByRegex(string $headerRegex) : array
    {
        $foundHeaders = [];
        $headerRegex = str_replace(".", "\.", $headerRegex);
        $headerRegex = str_replace("*", ".*", $headerRegex);
        $headerRegex = "#" . $headerRegex . "#";

        foreach ($this->headers as $key => $value) {
            if (preg_match($headerRegex, $key)) {
                $foundHeaders[$key] = $value;
            }
        }

        return $foundHeaders;
    }
1000897
private function getHttpHearders(array $headers)
    {
        $http_headers = array();
        foreach ($headers as $key => $value) {
            array_push($http_headers, $key . ":" . $value);
        }
        return $http_headers;
    }
692506
protected function normalizeBag($bag) : Collection
	{
		return Collection::make($bag)->filter(function ($item) {
			return is_string($item) ? trim($item) !== '' : $item;
		});
	}
617568
protected function getCacheLifetime(ResponseHeaderBag $headers)
    {
        $maxAge = 0;
        if ($headers->hasCacheControlDirective('max-age')) {
            $maxAge = $headers->getCacheControlDirective('max-age');
        }

        return $maxAge;
    }
928508
public function getHeaders()
    {
        $headerLines = [];
        foreach ($this->response->getHeaders() as $name => $lines)
        {
            foreach ($lines as $line)
            {
                $headerLines[] = "$name: $line";
            }
        }

        return HeaderBag::fromHeaderLines($headerLines);
    }