HeaderNameNormalizer   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
eloc 10
c 1
b 0
f 1
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UMA\Psr7Hmac\Internal;
6
7
final class HeaderNameNormalizer
8
{
9
    private static $specialSnowflakes = [
10
        'CONTENT_LENGTH' => 'content-length',
11
        'CONTENT_TYPE' => 'content-type',
12
    ];
13
14 132
    public static function normalize(string $name): string
15
    {
16 132
        if (\array_key_exists($name, self::$specialSnowflakes)) {
17 2
            return self::$specialSnowflakes[$name];
18
        }
19
20 132
        $normalized = \strtolower($name);
21
22 132
        if (0 === \strpos($normalized, 'http_')) {
23 2
            $normalized = \str_replace('_', '-', \substr($normalized, 5));
24
        }
25
26 132
        return $normalized;
27
    }
28
}
29