TenantAtlas/apps/platform/app/Support/Governance/Controls/CanonicalControlResolutionRequest.php
ahmido 6a5b8a3a11
Some checks failed
Main Confidence / confidence (push) Failing after 50s
feat: canonical control catalog foundation (#272)
## Summary
- add a config-seeded canonical control catalog plus shared resolution primitives and Microsoft subject bindings
- propagate canonical control references into findings-derived evidence snapshots and tenant review composition
- add the feature spec artifacts and focused Pest coverage, plus the supporting workspace and Sail helper adjustments included in this branch

## Testing
- cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Governance/CanonicalControlCatalogTest.php tests/Unit/Governance/CanonicalControlResolverTest.php tests/Feature/Governance/CanonicalControlResolutionIntegrationTest.php tests/Feature/Evidence/EvidenceSnapshotCanonicalControlReferenceTest.php tests/Feature/TenantReview/TenantReviewCanonicalControlReferenceTest.php tests/Feature/PlatformRelocation/CommandModelSmokeTest.php
- cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #272
2026-04-24 12:26:02 +00:00

66 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Governance\Controls;
final readonly class CanonicalControlResolutionRequest
{
public function __construct(
public string $provider,
public string $consumerContext,
public ?string $subjectFamilyKey = null,
public ?string $workload = null,
public ?string $signalKey = null,
) {}
/**
* @param array<string, mixed> $data
*/
public static function fromArray(array $data): self
{
return new self(
provider: self::normalize((string) ($data['provider'] ?? '')),
consumerContext: self::normalize((string) ($data['consumer_context'] ?? '')),
subjectFamilyKey: self::optionalString($data['subject_family_key'] ?? null),
workload: self::optionalString($data['workload'] ?? null),
signalKey: self::optionalString($data['signal_key'] ?? null),
);
}
public function hasDiscriminator(): bool
{
return $this->subjectFamilyKey !== null || $this->workload !== null || $this->signalKey !== null;
}
/**
* @return array{provider: string, subject_family_key: ?string, workload: ?string, signal_key: ?string, consumer_context: string}
*/
public function bindingContext(): array
{
return [
'provider' => $this->provider,
'subject_family_key' => $this->subjectFamilyKey,
'workload' => $this->workload,
'signal_key' => $this->signalKey,
'consumer_context' => $this->consumerContext,
];
}
private static function optionalString(mixed $value): ?string
{
if (! is_string($value)) {
return null;
}
$normalized = self::normalize($value);
return $normalized === '' ? null : $normalized;
}
private static function normalize(string $value): string
{
return trim($value);
}
}