src/SellerLabs/Nucleus/Support/Std.php
public static function castToBool($mixed)
    {
        if (is_string($mixed) || $mixed instanceof Rope) {
            $lower = Rope::of($mixed)->toLower();

            if ($lower->equals(Rope::of('true'))) {
                return true;
            } elseif ($lower->equals(Rope::of('false'))) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_int($mixed)) {
            if ($mixed === 1) {
                return true;
            } elseif ($mixed === 0) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_float($mixed)) {
            if ($mixed === 1.0) {
                return true;
            } elseif ($mixed === 0.0) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_bool($mixed)) {
            return $mixed;
        }

        throw new CoreException('Unable to cast into a bool.');
    }
public static function castToBool($mixed)
    {
        if (is_string($mixed) || $mixed instanceof Rope) {
            $lower = Rope::of($mixed)->toLower();

            if ($lower->equals(Rope::of('true'))) {
                return true;
            } elseif ($lower->equals(Rope::of('false'))) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_int($mixed)) {
            if ($mixed === 1) {
                return true;
            } elseif ($mixed === 0) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_float($mixed)) {
            if ($mixed === 1.0) {
                return true;
            } elseif ($mixed === 0.0) {
                return false;
            }

            throw new CoreException('Unable to cast into a bool.');
        } elseif (is_bool($mixed)) {
            return $mixed;
        }

        throw new CoreException('Unable to cast into a bool.');
    }
public static function castToBool ( $ mixed ) { if ( is_string ( $ mixed ) || $ mixed instanceof Rope ) { $ lower = Rope :: of ( $ mixed ) -> toLower ( ) ; if ( $ lower -> equals ( Rope :: of ( 'true' ) ) ) { return true ; } elseif ( $ lower -> equals ( Rope :: of ( 'false' ) ) ) { return false ; } throw new CoreException ( 'Unable to cast into a bool.' ) ; } elseif ( is_int ( $ mixed ) ) { if ( $ mixed === 1 ) { return true ; } elseif ( $ mixed === 0 ) { return false ; } throw new CoreException ( 'Unable to cast into a bool.' ) ; } elseif ( is_float ( $ mixed ) ) { if ( $ mixed === 1.0 ) { return true ; } elseif ( $ mixed === 0.0 ) { return false ; } throw new CoreException ( 'Unable to cast into a bool.' ) ; } elseif ( is_bool ( $ mixed ) ) { return $ mixed ; } throw new CoreException ( 'Unable to cast into a bool.' ) ; }
Attempt to cast a value into a bool.

@param mixed $mixed

@return bool
@throws CoreException
Attempt to cast a value into a bool .