1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 14:34:04 +00:00

add RandomIntGenerator

This commit is contained in:
Samuel Štancl 2025-01-17 13:42:50 +01:00
parent 8b131ed647
commit 4525e0f941
7 changed files with 44 additions and 4 deletions

View 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);
}
}