public static function mergeCurlOptions ($base, $additional) {
    if (null === $additional || empty($additional)) {
      return $base;
    }

    foreach ($additional as $key => $val) {
      if (!is_int($key)) {
        // treat non-numeric keys as CURLOPT_* constants to be resolved
        try {
          $curlkey = constant($key);
        } catch (Exception $ignored) {
          // no-op
        }
        if (null === $curlkey) {
          throw new \InvalidArgumentException("Invalid curl option [{$key}].");
        }
        $key = $curlkey;
      }
      if (CURLOPT_HTTPHEADER == $key &&
          array_key_exists(CURLOPT_HTTPHEADER, $base)) {
        // additional headers are cumlative
        if (is_array($val)) {
          // concatinate header collection
          foreach ($val as $header) {
            $base[CURLOPT_HTTPHEADER][] = $header;
          }
        } else {
          // add single header
          $base[CURLOPT_HTTPHEADER][] = $val;
        }

      } else {
        $base[$key] = $val;
      }
    } //end foreach

    return $base;
  }