public static function toBool($value)
    {
        if ($value instanceof Countable) {
            return (bool)count($value);
        }

        if (!static::isStringLike($value)) {
            return (bool)$value;
        }

        $string = "$value";

        if (trim($string) == '') {
            return false;
        }

        if (in_array(strtolower($value), ['0', 'false'], true)) {
            return false;
        }

        return (bool)$string;

    }
public static function toBool($value)
    {
        if ($value instanceof Countable) {
            return (bool)count($value);
        }

        if (!static::isStringLike($value)) {
            return (bool)$value;
        }

        $string = "$value";

        if (trim($string) == '') {
            return false;
        }

        if (in_array(strtolower($value), ['0', 'false'], true)) {
            return false;
        }

        return (bool)$string;

    }
public static function toBool ( $ value ) { if ( $ value instanceof Countable ) { return ( bool ) count ( $ value ) ; } if ( ! static :: isStringLike ( $ value ) ) { return ( bool ) $ value ; } $ string = "$value" ; if ( trim ( $ string ) == '' ) { return false ; } if ( in_array ( strtolower ( $ value ) , [ '0' , 'false' ] , true ) ) { return false ; } return ( bool ) $ string ; }
Cast a value to boolean.

@param mixed $value

@return bool
Cast a value to boolean .