Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5967085
StringGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
833 B
Referenced Files
None
Subscribers
None
StringGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
function
string
()
{
return
Generators
::
string
();
}
/**
* @template-implements Generator<string>
*/
class
StringGenerator
implements
Generator
{
public
function
__invoke
(
$size
,
RandomRange
$rand
)
{
$length
=
$rand
->
rand
(
0
,
$size
);
$built
=
''
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++)
{
$built
.=
chr
(
$rand
->
rand
(
33
,
126
));
}
return
GeneratedValueSingle
::
fromJustValue
(
$built
,
'string'
);
}
public
function
shrink
(
GeneratedValue
$element
)
{
if
(
$element
->
unbox
()
===
''
)
{
return
$element
;
}
return
GeneratedValueSingle
::
fromJustValue
(
substr
(
$element
->
unbox
(),
0
,
-
1
),
'string'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 12:07 (3 d, 14 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7d/85/0b42a69e34ea67bd04af7496873b
Default Alt Text
StringGenerator.php (833 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment