Well, that's what does the built-in filter.

echo filter_var("true", FILTER_VALIDATE_BOOLEAN); // echo (bool) true
echo filter_var("foo", FILTER_VALIDATE_BOOLEAN); // echo (bool) false
echo filter_var(null, FILTER_VALIDATE_BOOLEAN); // echo (bool) false

I think this filter will handle 95% of use cases without the all overhead. People that want a very specific filtring can implement a callback filter.