Skip to content

Commit 51f8d9a

Browse files
committed
✨ add hasHeader() method
Signed-off-by: otengkwame <[email protected]>
1 parent d105a8f commit 51f8d9a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

CodeIgniter/Framework/core/Input.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function has($index = null, $xss_clean = false)
283283

284284
return false;
285285
}
286-
286+
287287
/**
288288
* Fetch only items from the REQUEST array
289289
*
@@ -1222,6 +1222,18 @@ public function getRequestHeader($index, $xss_clean = false)
12221222
return $this->get_request_header($index, $xss_clean);
12231223
}
12241224

1225+
/**
1226+
* Check if a specific header exists.
1227+
*
1228+
* @param string $header
1229+
* @return bool
1230+
*/
1231+
public function hasHeader($header)
1232+
{
1233+
$headers = $this->requestHeaders();
1234+
return (bool) array_key_exists(strtolower($header), $headers);
1235+
}
1236+
12251237
// --------------------------------------------------------------------
12261238

12271239
/**

0 commit comments

Comments
 (0)