Ikwattro\GuzzleStereo\Formatter\ResponseFormatter::encodeResponsesCollection PHP Method

encodeResponsesCollection() public method

public encodeResponsesCollection ( array $responses )
$responses array
    public function encodeResponsesCollection(array $responses)
    {
        $formatted = [];
        foreach ($responses as $response) {
            $formatted[] = $this->formatResponse($response);
        }
        return json_encode($formatted, JSON_PRETTY_PRINT);
    }

Usage Example

示例#1
0
 /**
  * Returns the content of a specific tape without writing it to disk.
  *
  * @param string $name
  *
  * @return null|string
  */
 public function getTapeContent($name)
 {
     $tape = $this->getTape($name);
     if ($tape->hasResponses()) {
         $content = $this->formatter->encodeResponsesCollection($tape->getResponses());
         return $content;
     }
     return;
 }