VCR\Response::toArray PHP Method

toArray() public method

Returns an array representation of this Response.
public toArray ( ) : array
return array Array representation of this Request.
    public function toArray()
    {
        $body = $this->getBody();
        // Base64 encode when binary
        if (strpos($this->getContentType(), 'application/x-gzip') !== false || $this->getHeader('Content-Transfer-Encoding') == 'binary') {
            $body = base64_encode($body);
        }
        return array_filter(array('status' => $this->status, 'headers' => $this->getHeaders(), 'body' => $body));
    }

Usage Example

Esempio n. 1
0
 /**
  * Records a request and response pair.
  *
  * @param Request  $request  Request to record.
  * @param Response $response Response to record.
  *
  * @return void
  */
 public function record(Request $request, Response $response)
 {
     if ($this->hasResponse($request)) {
         return;
     }
     $recording = array('request' => $request->toArray(), 'response' => $response->toArray());
     $this->storage->storeRecording($recording);
 }