@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | * @param string $key |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public static function hasHeader(string $key): bool |
|
36 | - { |
|
37 | - list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key); |
|
35 | + public static function hasHeader(string $key): bool |
|
36 | + { |
|
37 | + list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key); |
|
38 | 38 | |
39 | - return isset(self::$__headers[$keyWithHyphens]) || isset(self::$__headers[$keyWithUnderscores]); |
|
40 | - } |
|
39 | + return isset(self::$__headers[$keyWithHyphens]) || isset(self::$__headers[$keyWithUnderscores]); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Gets the request header by given key |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function getHeader(string $key): ?string |
48 | 48 | { |
49 | - if (self::hasHeader($key)) { |
|
50 | - list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key); |
|
51 | - return self::$__headers[$keyWithHyphens] ?? self::$__headers[$keyWithUnderscores]; |
|
52 | - } |
|
49 | + if (self::hasHeader($key)) { |
|
50 | + list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key); |
|
51 | + return self::$__headers[$keyWithHyphens] ?? self::$__headers[$keyWithUnderscores]; |
|
52 | + } |
|
53 | 53 | |
54 | - return null; |
|
54 | + return null; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * @param string $key |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - private static function normalizeHeaderKey(string $key): array |
|
92 | - { |
|
93 | - $keyWithHyphens = str_replace('_', '-', strtolower($key)); |
|
94 | - $keyWithUnderscores = str_replace('-', '_', $key); |
|
95 | - return [$keyWithHyphens, $keyWithUnderscores]; |
|
96 | - } |
|
87 | + /** |
|
88 | + * @param string $key |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + private static function normalizeHeaderKey(string $key): array |
|
92 | + { |
|
93 | + $keyWithHyphens = str_replace('_', '-', strtolower($key)); |
|
94 | + $keyWithUnderscores = str_replace('-', '_', $key); |
|
95 | + return [$keyWithHyphens, $keyWithUnderscores]; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | \ No newline at end of file |