GraphQL\Utils::mapKeyValue PHP Method

mapKeyValue() public static method

public static mapKeyValue ( $traversable, callable $fn ) : array
$traversable
$fn callable
return array
    public static function mapKeyValue($traversable, callable $fn)
    {
        self::invariant(is_array($traversable) || $traversable instanceof \Traversable, __METHOD__ . ' expects array or Traversable');
        $map = [];
        foreach ($traversable as $key => $value) {
            list($newKey, $newValue) = $fn($value, $key);
            $map[$newKey] = $newValue;
        }
        return $map;
    }