TenantAtlas/app/Support/Tenants/TenantOperabilityDecision.php

47 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Tenants;
final readonly class TenantOperabilityDecision
{
public function __construct(
public TenantLifecycle $lifecycle,
public bool $canViewTenantSurface,
public bool $canSelectAsContext,
public bool $canOperate,
public bool $canArchive,
public bool $canRestore,
public bool $canResumeOnboarding,
public bool $canReferenceInWorkspaceMonitoring,
) {}
public function allowsAction(string $actionKey): bool
{
return match ($actionKey) {
'resume_onboarding' => $this->canResumeOnboarding,
'archive' => $this->canArchive,
'restore' => $this->canRestore,
default => false,
};
}
public function primaryManagementActionKey(bool $preferOnboarding = false): ?string
{
if ($preferOnboarding && $this->canResumeOnboarding) {
return 'resume_onboarding';
}
if ($this->canRestore) {
return 'restore';
}
if ($this->canArchive) {
return 'archive';
}
return null;
}
}