Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6069770
OneOfGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
OneOfGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
/**
* @return OneOfGenerator
*/
function
oneOf
(
/*$a, $b, ...*/
)
{
return
call_user_func_array
(
[
Generators
::
class
,
'oneOf'
],
func_get_args
()
);
}
/**
* @psalm-template T
* @template-implements Generator<Generator<T>>
*/
class
OneOfGenerator
implements
Generator
{
private
$generator
;
public
function
__construct
(
$generators
)
{
$this
->
generator
=
new
FrequencyGenerator
(
$this
->
allWithSameFrequency
(
$generators
));
}
public
function
__invoke
(
$size
,
RandomRange
$rand
)
{
return
$this
->
generator
->
__invoke
(
$size
,
$rand
);
}
public
function
shrink
(
GeneratedValue
$element
)
{
return
$this
->
generator
->
shrink
(
$element
);
}
private
function
allWithSameFrequency
(
$generators
)
{
return
array_map
(
function
(
$generator
)
{
return
[
1
,
$generator
];
},
$generators
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 5 2026, 06:11 (6 w, 12 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cf/74/10d2caea65197e994221f3162fd7
Default Alt Text
OneOfGenerator.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment