-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to grab a token from a policy and to conclude whet…
…her it is valid for processing.
- Loading branch information
1 parent
4eaf705
commit 3f3b82d
Showing
2 changed files
with
49 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Dovu\GuardianPhpSdk\Domain; | ||
|
||
class GuardianToken | ||
{ | ||
public function __construct(public object $token) | ||
{ | ||
} | ||
|
||
public static function none(): self | ||
{ | ||
return new self((object) [ | ||
"adminId" => null, | ||
"tokenId" => "" | ||
]); | ||
} | ||
|
||
|
||
/** | ||
* When "adminId" from parent obj is falsely then ignore "id()" fn in client. | ||
* | ||
* Usually this would indicate a "published" policy over a "dry run" state. | ||
* | ||
* @return bool | ||
*/ | ||
public function hasValidToken(): bool | ||
{ | ||
return !!! $this->token->adminId; | ||
} | ||
|
||
public function id(): string | ||
{ | ||
return $this->token->tokenId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters