If your "boolean" variable comes from a global array such as $_POST and $_GET, you can use filter_input()
filter function.
Example for POST:
$isSleeping = filter_input(INPUT_POST, 'is_sleeping', FILTER_VALIDATE_BOOLEAN);
If your "boolean" variable comes from other source you can use filter_var()
filter function.
Example:
filter_var('true', FILTER_VALIDATE_BOOLEAN); // true