mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 23:54:04 +00:00
* add RandomIntGenerator * remove string assertions * make int ranges configurable * update test to use min & max
22 lines
537 B
PHP
22 lines
537 B
PHP
<?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.
|
|
*/
|
|
class RandomIntGenerator implements UniqueIdentifierGenerator
|
|
{
|
|
public static int $min = 0;
|
|
public static int $max = PHP_INT_MAX;
|
|
|
|
public static function generate(Model $model): string|int
|
|
{
|
|
return random_int(static::$min, static::$max);
|
|
}
|
|
}
|