<?php

namespace ReallySimplePlugins\RSS\Core\Features\Vulnerability\Traits;

use ReallySimplePlugins\RSS\Core\Bootstrap\App;
use ReallySimplePlugins\RSS\Core\Features\Vulnerability\Support\Helpers\VulnerabilityConfig;

trait HasFrontendUrl
{
    /**
     * Returns the public URL for a vulnerability detail page.
     */
    public function getFrontendUrl(
        string $type,
        string $slug,
        string $vulnerabilityUuid
    ): string {
        if ($vulnerabilityUuid === '' || $vulnerabilityUuid === '0') {
            return '';
        }

        $baseUrl = App::getInstance()->get(VulnerabilityConfig::class)->getUrl('client.base_uri');

        return sprintf(
            $baseUrl . '/%s/%s/%s',
            $type,
            $slug,
            $vulnerabilityUuid
        );
    }
}
