| Total Complexity | 4 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | class SiteUrlProvider implements SiteUrlProviderInterface, TenantProviderAwareInterface |
||
| 23 | { |
||
| 24 | public function __construct( |
||
| 25 | private string $domain, |
||
| 26 | private string $siteUrl, |
||
| 27 | private TenantProviderInterface $tenantProvider |
||
| 28 | ) { |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getSiteUrl(): string |
||
| 32 | { |
||
| 33 | try { |
||
| 34 | $tenant = $this->tenantProvider->getCurrentTenant(); |
||
| 35 | |||
| 36 | return sprintf('https://%s.%s', $tenant->getSubdomain(), $this->domain); |
||
| 37 | } catch (NoTenantFoundException $exception) { |
||
| 38 | return $this->siteUrl; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | public function setTenantProvider(TenantProviderInterface $tenantProvider): void |
||
| 45 | } |
||
| 46 | } |
||
| 47 |