Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5965218
ElementsGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
877 B
Referenced Files
None
Subscribers
None
ElementsGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
function
elements
(
/*$a, $b, ...*/
)
{
return
call_user_func_array
(
[
Generators
::
class
,
'elements'
],
func_get_args
()
);
}
/**
* @psalm-template T
* @template-implements Generator<T>
*/
class
ElementsGenerator
implements
Generator
{
private
$domain
;
public
static
function
fromArray
(
array
$domain
)
{
return
new
self
(
$domain
);
}
private
function
__construct
(
$domain
)
{
$this
->
domain
=
$domain
;
}
public
function
__invoke
(
$_size
,
RandomRange
$rand
)
{
$index
=
$rand
->
rand
(
0
,
count
(
$this
->
domain
)
-
1
);
return
GeneratedValueSingle
::
fromJustValue
(
$this
->
domain
[
$index
],
'elements'
);
}
public
function
shrink
(
GeneratedValue
$element
)
{
return
$element
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 10:49 (1 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c7/b6/0e3e7c09648c29dc68c012e7983e
Default Alt Text
ElementsGenerator.php (877 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment