$context */ public function __construct( public readonly Principal $principal, public readonly string $action, public readonly string $resource = '', public readonly array $context = [], ) { } /** * @since 0.1.0 */ public function get(string $key, mixed $default = null): mixed { return array_key_exists($key, $this->context) ? $this->context[$key] : $default; } /** * Whether the action is one of `$actions`; a trailing `*` matches a prefix (`tool.*`). * * @since 0.1.0 */ public function is(string ...$actions): bool { foreach ($actions as $action) { if ($action === $this->action || (str_ends_with($action, '*') && str_starts_with($this->action, substr($action, 0, -1)))) { return true; } } return false; } }