+ /**
+ * @param API $api
+ * @param string $type
+ * @return API
+ */
+ static function apply(API $api, string $type) : API {
+ $part = "[^()<>@,;:\\\"\/\[\]?.=[:space:][:cntrl:]]+";
+ if (preg_match("/^$part\/$part\$/", $type)) {
+ $that = $api->withHeader("Accept", $type);
+ } else {
+ switch (substr($type, 0, 1)) {
+ case "+":
+ case ".":
+ case "":
+ break;
+ default:
+ $type = ".$type";
+ break;
+ }
+ $vapi = static::version();
+ $that = $api->withHeader("Accept", "application/vnd.github.v$vapi$type");
+ }
+ return $that;
+ }
+