Skip to content

Commit

Permalink
enh: simplify code #11
Browse files Browse the repository at this point in the history
  • Loading branch information
kamarton committed Dec 19, 2024
1 parent 2109144 commit 6364578
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Helpers/HttpHeaderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public static function getFirstHeaderValue(array $headers, string $name): ?strin
{
$name = strtolower($name);
foreach ($headers as $key => $value) {
if (strtolower($key) === $name) {
if(!is_array($value)) {
return $value;
}
$firstValue = reset($value);
if(false === $firstValue) {
return null;
}
return $firstValue;
if (strtolower($key) !== $name) {
continue;
}
if(!is_array($value)) {
return $value;
}
$firstValue = reset($value);
if(false === $firstValue) {
return null;
}
return $firstValue;
}
return null;
}
Expand Down

0 comments on commit 6364578

Please sign in to comment.