47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\WorkspaceIsolation;
|
|
|
|
use RuntimeException;
|
|
|
|
class WorkspaceIsolationViolation extends RuntimeException
|
|
{
|
|
public static function missingTenantId(string $modelClass): self
|
|
{
|
|
return new self(sprintf('%s must include a tenant_id.', $modelClass));
|
|
}
|
|
|
|
public static function tenantNotFound(string $modelClass, int $tenantId): self
|
|
{
|
|
return new self(sprintf('%s references missing tenant_id %d.', $modelClass, $tenantId));
|
|
}
|
|
|
|
public static function tenantWorkspaceMissing(string $modelClass, int $tenantId): self
|
|
{
|
|
return new self(sprintf('%s tenant_id %d has no workspace_id mapping.', $modelClass, $tenantId));
|
|
}
|
|
|
|
public static function workspaceMismatch(string $modelClass, int $tenantId, int $expectedWorkspaceId, int $actualWorkspaceId): self
|
|
{
|
|
return new self(sprintf(
|
|
'%s tenant_id %d requires workspace_id %d, received %d.',
|
|
$modelClass,
|
|
$tenantId,
|
|
$expectedWorkspaceId,
|
|
$actualWorkspaceId,
|
|
));
|
|
}
|
|
|
|
public static function tenantImmutable(string $modelClass, int $originalTenantId, int $updatedTenantId): self
|
|
{
|
|
return new self(sprintf(
|
|
'%s tenant_id is immutable (%d -> %d).',
|
|
$modelClass,
|
|
$originalTenantId,
|
|
$updatedTenantId,
|
|
));
|
|
}
|
|
}
|