random_int
laravel/framework
Supported Versions: PHP 7, PHP 8
Generates cryptographically secure pseudo-random integers
random_int
(
int $min
,
int $max
):
int
$acquired
=
$updated
>=
1
;
}
if (
random_int
(
1
,
$this
->
lottery
[
1
]) <=
$this
->
lottery
[
0
]) {
$this
->
connection
->
table
(
$this
->
table
)->
where
(
'expiration'
,
'<='
,
time
())->
delete
();
}
src/Illuminate/Cache/DatabaseLock.php
protected function
configHitsLottery
(array
$config
)
{
return
random_int
(
1
,
$config
[
'lottery'
][
1
]) <=
$config
[
'lottery'
][
0
];
}
src/Illuminate/Session/Middleware/StartSession.php
public function
testDefaultCacheLifeTimeIsSetOnTaggableStore
()
{
$repo
= new
Repository
(new
ArrayStore
());
$repo
->
setDefaultCacheTime
(
random_int
(
1
,
100
));
$store
=
$repo
->
tags
(
'foo'
);
tests/Cache/CacheRepositoryTest.php
public function
register
()
{
$this
->
app
->
bind
(
'one.time.password'
, function () {
return
random_int
(
1
,
10
);
});
Queue
::
createPayloadUsing
(function () {
tests/Integration/Queue/CustomPayloadTest.php
public function
testRandom
()
{
$this
->
assertEquals
(
16
,
strlen
(
Str
::
random
()));
$randomInteger
=
random_int
(
1
,
100
);
$this
->
assertEquals
(
$randomInteger
,
strlen
(
Str
::
random
(
$randomInteger
)));
$this
->
assertIsString
(
Str
::
random
());
}
tests/Support/SupportStrTest.php