NeedsParseHeaders   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 8
c 1
b 0
f 1
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseHeaders() 0 18 3
1
<?php
2
3
namespace EasyHttp\GuzzleLayer\Concerns;
4
5
trait NeedsParseHeaders
6
{
7 7
    protected function parseHeaders(array $headers): array
8
    {
9 7
        $_headers = [];
10
11 7
        foreach ($headers as $key => $value) {
12
            /**
13
             * RFC 7230, section 3.2.2 allows multiple Set-Cookie headers
14
             * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2
15
             */
16 7
            if (strtolower($key) === 'set-cookie') {
17 1
                $_headers[$key] = $value;
18 1
                continue;
19
            }
20
21 7
            $_headers[$key] = array_shift($value);
22
        }
23
24 7
        return $_headers;
25
    }
26
}
27