public static function make($resource = '', $mode = 'w+b')
    {
        switch (gettype($resource)) {
            case 'resource':
                return (new static(false))->setResource($resource, $mode);
            case 'string':
                $stream = fopen('php://temp', $mode);
                if ($resource !== '') {
                    fwrite($stream, $resource);
                    fseek($stream, 0);
                }

                return (new static(false))->setResource($stream, $mode);
            case 'object':
                if ($resource instanceof self) {
                    return $resource;
                } elseif (method_exists($resource, '__toString')) {
                    $resource = (string) $resource;

                    return static::make($resource, $mode);
                }
            default:
                throw new InvalidArgumentException(sprintf(
                    'Invalid resource "%s" provided.',
                    is_object($resource) ? get_class($resource)
                                         : gettype($resource)
                ));
        }
    }