Lime\Helper\Utils::str_to_bool PHP Method

str_to_bool() public static method

Supports 'y', 'n', 'yes', 'no' and a few other variations.
public static str_to_bool ( string $string, boolean $default = false ) : boolean
$string string The string to convert to boolean
$default boolean The value to return if we can't match any yes/no words
return boolean
    public static function str_to_bool($string, $default = false)
    {
        $yes_words = 'affirmative|all right|aye|indubitably|most assuredly|ok|of course|okay|sure thing|y|yes+|yea|yep|sure|yeah|true|t|on|1|oui|vrai';
        $no_words = 'no*|no way|nope|nah|na|never|absolutely not|by no means|negative|never ever|false|f|off|0|non|faux';
        if (preg_match('/^(' . $yes_words . ')$/i', $string)) {
            return true;
        } else {
            if (preg_match('/^(' . $no_words . ')$/i', $string)) {
                return false;
            }
        }
        return $default;
    }