mirror of
https://gh.wpcy.net/https://github.com/fairpm/aspirecloud.git
synced 2026-06-20 02:22:28 +08:00
23 lines
657 B
PHP
23 lines
657 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Packages;
|
|
|
|
use App\Models\Package;
|
|
|
|
class PackageDIDService
|
|
{
|
|
public function generateWebDid(string $type, string $slug): string
|
|
{
|
|
$domain = config('fair.domains.webdid')
|
|
?? \Safe\parse_url(config('app.url'), PHP_URL_HOST)
|
|
?? throw new \RuntimeException('Cannot determine WEB DID domain from FAIR_DOMAINS_WEBDID or APP_URL');
|
|
|
|
return sprintf('did:web:%s:packages:%s:%s', $domain, $type, $slug);
|
|
}
|
|
|
|
public function generatePackageWebDid(Package $package): string
|
|
{
|
|
return $this->generateWebDid($package->type, $package->slug);
|
|
}
|
|
}
|