/**
  * Factory method that allows for easy instantiation from a Response object.
  *
  * @param Response        $response
  * @param AbstractService $service
  * @return static
  */
 public static function fromResponse(Response $response, AbstractService $service)
 {
     $object = new static($service);
     if (null !== ($headers = $response->getHeaders())) {
         $object->setMetadata($headers, true);
     }
     return $object;
 }
Beispiel #2
0
 /**
  * Takes a response and stocks common values from both the body and the headers.
  *
  * @param Response $response
  * @return $this
  */
 public function populateFromResponse(Response $response)
 {
     $this->content = $response->getBody();
     $headers = $response->getHeaders();
     return $this->setMetadata($headers, true)->setContentType((string) $headers['Content-type'])->setLastModified((string) $headers['Last-Modified'])->setContentLength((string) $headers['Content-Length'])->setEtag((string) $headers['ETag']);
 }