Add an increment to duplicate headers

So the following line:
|duplicate|duplicate|duplicate|
|first    |second   |third    |

Yields value:
$duplicate => 'first', $duplicate1 => 'second', $duplicate2 => 'third'

@param array $headers

@return array
352972
protected function incrementHeaders(array $headers)
    {
        $incrementedHeaders = [];
        foreach (array_count_values($headers) as $header => $count) {
            if ($count > 1) {
                $incrementedHeaders[] = $header;
                for ($i = 1; $i < $count; $i++) {
                    $incrementedHeaders[] = $header . $i;
                }
            } else {
                $incrementedHeaders[] = $header;
            }
        }

        return $incrementedHeaders;
    }
110987
public function appendHeaders(array $headers = [])
    {
        // Append headers.
        $this->headers = collect($this->headers)->merge($headers)->all();

        // Return calling object.
        return $this;
    }
1216085
public function header($headers) {
        // Record HTTP header
        if (is_array($headers)) {
            foreach ($headers as $header) {
                array_push($this->_headers, $header);
            }
        } else if (is_string($headers)) {
            array_push($this->_headers, $headers);
        }
        
        return $this;
    }
820300
public function setMultiple(array $headers): HeaderCollection
    {
        foreach ($headers as $key => $value) {
            $key = $this->getKey($key, true);
            $this->headers[$key] = $value;
        }
        return $this;
    }
1115370
public function headers(array $headers): HttpRequest
    {
        foreach ($headers as $name => $value) {
            $this->header($name, $value);
        }

        return $this;
    }
955864
protected function addCredentials(array $headers)
    {

        if (!$this->user || !$this->password) {
            return $headers;
        }

        // Check if credentials are already in headers
        foreach ($headers as $line) {
            if (stripos(trim($line),'authorization: basic') === 0) {
                return $headers;
            }
        }

        $auth = $this->user . ':' . $this->password;

        $headers[] = 'Authorization: Basic ' . base64_encode("$auth");

        return $headers;

    }
1334356
public function setHeaders(array $headers = []): Headers
    {
        $this->headers = array();

        foreach ($headers as $header => $data) {
            $this->setHeader((string)$header, (string)$data);
        }

        return $this;
    }
357455
public function setHeaders(array $headers)
    {
        $this->headers = [];
        foreach ($headers as $name => $val) {
            $this->addHeader($name, $val);
        }
        return $this;
    }
1279500
private function getPresignHeaders(array $headers)
    {
        $presignHeaders = [];
        $blacklist = $this->getHeaderBlacklist();
        foreach ($headers as $name => $value) {
            $lName = strtolower($name);
            if (!isset($blacklist[$lName])
                && $name !== self::AMZ_CONTENT_SHA256_HEADER
            ) {
                $presignHeaders[] = $lName;
            }
        }
        return $presignHeaders;
    }
722983
public function headers( array $headers )
      : Request
   {

      $this->_defaultHeaders = array_merge( $this->_defaultHeaders, $headers );

      return $this;

   }
177673
private function normalizeRequestHeaders(array $headers)
    {
        // Explicitly set an empty Expect header, so that the server will not
        // respond with a "100 Continue" status code for large uploads.
        $emptyExpectHeader = 'Expect: ';
        $haveExpectHeader = false;

        for ($i = 0; $i < count($headers); $i++) {
            if ($this->isExpectHeader($headers[$i])) {
                // There is already an expect header - let's set it to empty
                $headers[$i] = $emptyExpectHeader;
                $haveExpectHeader = true;
                break;
            }
        }

        if (!$haveExpectHeader) {
            // There is no expect header - let's add one
            $headers[] = $emptyExpectHeader;
        }

        return $headers;
    }
235351
public function addHeaders(array $headers)
    {
        foreach ($headers as $name => $value) {
            $this->headers->add($name, $value);
        }
    }
353982
public function header(array $headers) {

        $formattedHeaders = [];

        $combinedHeaders = array_change_key_case(array_merge($this->header, $headers));

        foreach ($combinedHeaders as $key => $val)

            $formattedHeaders[] = trim(strtolower($key)) . ':' . $val;

        $this->header = $formattedHeaders;

        return $this;

    }
900588
public function prepend($headers, $value = '')
    {
        if (is_string($headers) && func_num_args() === 2) {
            $headers = [$headers => $value];
        }
        return $this->_set($headers, true);
    }
674880
public function addRequestHeaders($headers)
    {
        $currency = $this->client->getCurrencyCode();
        if (!empty($currency)) {
            $headers['X-MOLTIN-CURRENCY'] = $this->client->getCurrencyCode();
        }
        return $headers;
    }
700222
public function withHeaders($headers)
    {
        if ($headers instanceof HeaderBag) {
            $headers = $headers->all();
        }

        foreach ($headers as $key => $value) {
            $this->headers->set($key, $value);
        }

        return $this;
    }
978137
private function parseHeaders(array $headers)
    {
        $indexes = [];
        $metas   = [];

        foreach ($headers as $key => $value) {
            $key = strtolower($key);

            if (strpos($key, 'x-riak-index-') === 0) {
                $name  = substr($key, 13);
                $value = isset($indexes[$name])
                    ? array_merge($indexes[$name], $value)
                    : $value;

                $indexes[$name] = $value;
            }

            if (strpos($key, 'x-riak-meta-') === 0) {
                $name  = strtolower(substr($key, 12));
                $value = is_array($value)
                    ? reset($value)
                    : $value;

                $metas[$name] = $value;
            }
        }

        return [
            'indexes' => $indexes,
            'metas'   => $metas
        ];
    }