NeedsParseHeaders::parseHeaders()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
cc 3
nc 3
nop 1
crap 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