mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:34:04 +00:00
add RandomIntGenerator
This commit is contained in:
parent
8b131ed647
commit
4525e0f941
7 changed files with 44 additions and 4 deletions
21
src/UniqueIdentifierGenerators/RandomIntGenerator.php
Normal file
21
src/UniqueIdentifierGenerators/RandomIntGenerator.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\UniqueIdentifierGenerators;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
||||
|
||||
/**
|
||||
* Generates a cryptographically secure random integer for the tenant key.
|
||||
*
|
||||
* The integer is generated in range (0, PHP_INT_MAX).
|
||||
*/
|
||||
class RandomIntGenerator implements UniqueIdentifierGenerator
|
||||
{
|
||||
public static function generate(Model $model): string|int
|
||||
{
|
||||
return random_int(0, PHP_INT_MAX);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue