Page MenuHomeWickedGov Phorge

MapGenerator.php
No OneTemporary

Size
1013 B
Referenced Files
None
Subscribers
None

MapGenerator.php

<?php
namespace Eris\Generator;
use Eris\Generator;
use Eris\Generators;
use Eris\Random\RandomRange;
// TODO: support calls like ($function . $generator)
function map(callable $function, Generator $generator)
{
return Generators::map($function, $generator);
}
/**
* @psalm-template T
* @template-implements Generator<T>
*/
class MapGenerator implements Generator
{
private $map;
private $generator;
public function __construct(callable $map, $generator)
{
$this->map = $map;
$this->generator = $generator;
}
public function __invoke($_size, RandomRange $rand)
{
$input = $this->generator->__invoke($_size, $rand);
return $input->map(
$this->map,
'map'
);
}
public function shrink(GeneratedValue $value)
{
$input = $value->input();
$shrunkInput = $this->generator->shrink($input);
return $shrunkInput->map(
$this->map,
'map'
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 07:59 (1 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bb/84/be98db63ef438347e3b82e937e00
Default Alt Text
MapGenerator.php (1013 B)

Event Timeline