forked from fa/breadcrumb-the-shire
Remove subset/duplicate architecture tests already covered by broader checks, and replace assertTrue(true) with self::addToAssertionCount(1) for explicit no-exception-thrown intent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
618 B
PHP
23 lines
618 B
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Access;
|
|
|
|
trait AuthorizationPolicyContextTrait
|
|
{
|
|
protected function actorUserId(array $context): int
|
|
{
|
|
return (int) ($context['actor_user_id'] ?? 0);
|
|
}
|
|
|
|
protected function hasPermission(int $userId, string $permissionKey): bool
|
|
{
|
|
return $userId > 0 && $this->permissionService->userHas($userId, $permissionKey);
|
|
}
|
|
|
|
protected function capabilitiesFromDecision(AuthorizationDecision $decision): array
|
|
{
|
|
$capabilities = $decision->attribute('capabilities', []);
|
|
return is_array($capabilities) ? $capabilities : [];
|
|
}
|
|
}
|