Ejemplo n.º 1
0
Archivo: API.php Proyecto: m6w6/seekat
 /**
  * Create a copy of the endpoint with a customized accept header
  *
  * Changes the returned endpoint's accept header to "application/vnd.github.v3.{$type}"
  *
  * @param string $type The expected return data type, e.g. "raw", "html", etc.
  * @param bool $keepdata Whether to keep already fetched data
  * @return API clone
  */
 function as(string $type, bool $keepdata = true) : API
 {
     switch (substr($type, 0, 1)) {
         case "+":
         case ".":
         case "":
             break;
         default:
             $type = ".{$type}";
             break;
     }
     $vapi = ContentType::version();
     $that = $this->withHeader("Accept", "application/vnd.github.v{$vapi}{$type}");
     if (!$keepdata) {
         $that->__data = null;
     }
     return $that;
 }