code: 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) {
              [$newKey, $newValue] = $fn($value, $key);
              $map[$newKey]        = $newValue;
          }
  
          return $map;
      }
docs: @param mixed|Traversable $traversable
  
  @return mixed[]
  
  @throws Exception