Skip to content

Commit 71e316d

Browse files
committed
✨ add boolify() helper function
Signed-off-by: otengkwame <[email protected]>
1 parent e03b598 commit 71e316d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

CodeIgniter/Framework/core/Common.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,25 @@ function is($key, $value = null)
186186

187187
// ------------------------------------------------------------------------
188188

189+
if ( ! function_exists('boolify'))
190+
{
191+
/**
192+
* Convert common true/false strings into boolean values
193+
*
194+
* @param int|string $status
195+
* @return bool
196+
*/
197+
function boolify(int|string $status)
198+
{
199+
return filter_var(
200+
$status,
201+
FILTER_VALIDATE_BOOLEAN
202+
);
203+
}
204+
}
205+
206+
// ------------------------------------------------------------------------
207+
189208
if ( ! function_exists('is_blank'))
190209
{
191210
/**

0 commit comments

Comments
 (0)