In a similar vein, converting flags to booleans proper:
<?php
function return_boolean($val)
{
static $map = array ('on' => true, 'true' => true, 'off' => false, 'false' => false);
return @($map[strtolower($val)] ?: (bool)$val);
}
?>
If you're using PHP >= 7, consider replacing ?: with ?? and removing the @ silencer.