-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #172 use stable agent token for the generated data
- Loading branch information
1 parent
e59fc5e
commit a9f5c2b
Showing
4 changed files
with
38 additions
and
4 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
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
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,32 @@ | ||
<?php | ||
|
||
namespace App\Util; | ||
|
||
use Illuminate\Support\Str; | ||
use RuntimeException; | ||
|
||
class AgentToken | ||
{ | ||
protected static $useFakeToken = false; | ||
|
||
protected static $fakeToken = null; | ||
|
||
public static function useFakeToken(string $token): void | ||
{ | ||
self::$fakeToken = $token; | ||
self::$useFakeToken = true; | ||
} | ||
|
||
public static function make(): string | ||
{ | ||
if (self::$useFakeToken) { | ||
if (self::$fakeToken === null) { | ||
throw new RuntimeException('Fake token is not set'); | ||
} | ||
|
||
return self::$fakeToken; | ||
} | ||
|
||
return Str::random(42); | ||
} | ||
} |
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