public static function toBoolean($str)
    {
        if (!is_string($str)) {
            throw new InvalidArgumentException(sprintf('String expected, %s received', gettype($str)));
        }

        $booleanTrue = array(
            '1',
            'on',
            'true',
            'yes',
        );
        if (in_array($str, $booleanTrue, true)) {
            return true;
        }
        $booleanFalse = array(
            '0',
            'off',
            'false',
            'no',
        );
        if (in_array($str, $booleanFalse, true)) {
            return false;
        }

        return false;
    }
public static function toBoolean($str)
    {
        if (!is_string($str)) {
            throw new InvalidArgumentException(sprintf('String expected, %s received', gettype($str)));
        }

        $booleanTrue = array(
            '1',
            'on',
            'true',
            'yes',
        );
        if (in_array($str, $booleanTrue, true)) {
            return true;
        }
        $booleanFalse = array(
            '0',
            'off',
            'false',
            'no',
        );
        if (in_array($str, $booleanFalse, true)) {
            return false;
        }

        return false;
    }
public static function toBoolean ( $ str ) { if ( ! is_string ( $ str ) ) { throw new InvalidArgumentException ( sprintf ( 'String expected, %s received' , gettype ( $ str ) ) ) ; } $ booleanTrue = array ( '1' , 'on' , 'true' , 'yes' , ) ; if ( in_array ( $ str , $ booleanTrue , true ) ) { return true ; } $ booleanFalse = array ( '0' , 'off' , 'false' , 'no' , ) ; if ( in_array ( $ str , $ booleanFalse , true ) ) { return false ; } return false ; }
Converts a string to boolean

@param  string  $str
@return boolean
Converts a string to boolean