Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Add sorting and equality function to Scope
Browse files Browse the repository at this point in the history
The commit includes the addition of a sorting step in the Scope constructor that ensures that the order of scope values is consistent. Also, a new method 'equal' has been added to compare if two scope instances are equal based on their values.

Signed-off-by: mesilov <[email protected]>
  • Loading branch information
mesilov committed Jul 6, 2024
1 parent e4e36a8 commit b460b22
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Core/Credentials/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Scope
public function __construct(array $scope = [])
{
$scope = array_unique(array_map('strtolower', $scope));

sort($scope);
if (count($scope) === 1 && $scope[0] === '') {
$scope = [];
} else {
Expand All @@ -98,6 +98,11 @@ public function __construct(array $scope = [])
$this->currentScope = $scope;
}

public function equal(self $scope): bool
{
return $this->currentScope === $scope->getScopeCodes();
}

public function getScopeCodes(): array
{
return $this->currentScope;
Expand Down

0 comments on commit b460b22

Please sign in to comment.