···55use SocialDept\AtpClient\Data\Credentials;
66use SocialDept\AtpClient\Data\DPoPKey;
77use SocialDept\AtpClient\Enums\AuthType;
88+use SocialDept\AtpClient\Enums\Scope;
89910class Session
1011{
···6263 public function hasScope(string $scope): bool
6364 {
6465 return in_array($scope, $this->credentials->scope, true);
6666+ }
6767+6868+ /**
6969+ * Check if the session has the given scope (alias for hasScope with Scope enum support).
7070+ */
7171+ public function can(string|Scope $scope): bool
7272+ {
7373+ $scopeValue = $scope instanceof Scope ? $scope->value : $scope;
7474+7575+ return $this->hasScope($scopeValue);
7676+ }
7777+7878+ /**
7979+ * Check if the session has any of the given scopes.
8080+ *
8181+ * @param array<string|Scope> $scopes
8282+ */
8383+ public function canAny(array $scopes): bool
8484+ {
8585+ foreach ($scopes as $scope) {
8686+ if ($this->can($scope)) {
8787+ return true;
8888+ }
8989+ }
9090+9191+ return false;
9292+ }
9393+9494+ /**
9595+ * Check if the session has all of the given scopes.
9696+ *
9797+ * @param array<string|Scope> $scopes
9898+ */
9999+ public function canAll(array $scopes): bool
100100+ {
101101+ foreach ($scopes as $scope) {
102102+ if (! $this->can($scope)) {
103103+ return false;
104104+ }
105105+ }
106106+107107+ return true;
108108+ }
109109+110110+ /**
111111+ * Check if the session does NOT have the given scope.
112112+ */
113113+ public function cannot(string|Scope $scope): bool
114114+ {
115115+ return ! $this->can($scope);
65116 }
6611767118 public function authType(): AuthType