Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6117164
AssociativeArrayGenerator.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
AssociativeArrayGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
/**
* @return AssociativeArrayGenerator
*/
function
associative
(
array
$generators
)
{
return
Generators
::
associative
(
$generators
);
}
/**
* @template-implements Generator<array<string, mixed>>
*/
class
AssociativeArrayGenerator
implements
Generator
{
private
$generators
;
private
$tupleGenerator
;
public
function
__construct
(
array
$generators
)
{
$this
->
generators
=
$generators
;
$this
->
tupleGenerator
=
new
TupleGenerator
(
array_values
(
$generators
));
}
public
function
__invoke
(
$size
,
RandomRange
$rand
)
{
$tuple
=
$this
->
tupleGenerator
->
__invoke
(
$size
,
$rand
);
return
$this
->
mapToAssociativeArray
(
$tuple
);
}
public
function
shrink
(
GeneratedValue
$element
)
{
$input
=
$element
->
input
();
$shrunkInput
=
$this
->
tupleGenerator
->
shrink
(
$input
);
return
$this
->
mapToAssociativeArray
(
$shrunkInput
);
}
private
function
mapToAssociativeArray
(
GeneratedValue
$tuple
)
{
return
$tuple
->
map
(
function
(
$value
)
{
$associativeArray
=
[];
$keys
=
array_keys
(
$this
->
generators
);
for
(
$i
=
0
,
$iMax
=
count
(
$value
);
$i
<
$iMax
;
$i
++)
{
$key
=
$keys
[
$i
];
$associativeArray
[
$key
]
=
$value
[
$i
];
}
return
$associativeArray
;
},
'associative'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 7 2026, 01:13 (6 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
3a/f4/f8efe52710acfdd7ae9ee6d7d2e3
Default Alt Text
AssociativeArrayGenerator.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment