protected function createTemporaryFile($content)
    {
        $temporaryPath = $this->getTemporaryPath();

        if (false === $temporaryPath) {
            throw new RuntimeException("Unable to create temporary file in '{$temporaryPath}'.");
        }

        file_put_contents($temporaryPath, $content);

        // The file is automatically removed when closed, or when the script ends.
        register_shutdown_function(function () use ($temporaryPath) {
            unlink($temporaryPath);
        });

        return $temporaryPath;
    }