Eris\Generator\GeneratedValue::map PHP Method

map() public method

public map ( callable $applyToValue, $generatorName ) : GeneratedValue
$applyToValue callable
return GeneratedValue
    public function map(callable $applyToValue, $generatorName)
    {
        return new self($applyToValue($this->value), $this, $generatorName);
    }

Usage Example

 private function mapToAssociativeArray(GeneratedValue $tuple)
 {
     return $tuple->map(function ($value) {
         $associativeArray = [];
         $keys = array_keys($this->generators);
         for ($i = 0; $i < count($value); $i++) {
             $key = $keys[$i];
             $associativeArray[$key] = $value[$i];
         }
         return $associativeArray;
     }, 'associative');
 }