public static function keyMap($traversable, callable $keyFn)
    {
        self::invariant(
            is_array($traversable) || $traversable instanceof Traversable,
            __METHOD__ . ' expects array or Traversable'
        );

        $map = [];
        foreach ($traversable as $key => $value) {
            $newKey = $keyFn($value, $key);
            if (! is_scalar($newKey)) {
                continue;
            }

            $map[$newKey] = $value;
        }

        return $map;
    }
public static function keyMap($traversable, callable $keyFn)
    {
        self::invariant(
            is_array($traversable) || $traversable instanceof Traversable,
            __METHOD__ . ' expects array or Traversable'
        );

        $map = [];
        foreach ($traversable as $key => $value) {
            $newKey = $keyFn($value, $key);
            if (! is_scalar($newKey)) {
                continue;
            }

            $map[$newKey] = $value;
        }

        return $map;
    }
@param mixed|Traversable $traversable

@return mixed[]

@throws Exception