public static function sendAttachment($source, ResponseInterface $response = null, $options = [])
    {
        $stream = $source;

        if (!$stream instanceof StreamInterface) {
            $stream = new Stream($stream, 'r');
        }

        /** @var ResponseInterface $response */
        $response = $response ?: new Response();

        $filename = null;

        if (is_string($source)) {
            $filename = pathinfo($source, PATHINFO_BASENAME);
        }

        if (isset($options['filename'])) {
            $filename = $options['filename'];
        }

        $response = HeaderHelper::prepareAttachmentHeaders($response, $filename);

        $response = $response->withBody($stream);

        $output = static::$outputObject;

        if (!$output instanceof StreamOutput) {
            $output = new StreamOutput();
        }

        if (isset($options['delay'])) {
            $output->setDelay($options['delay']);
        }

        $output->respond($response);
    }