createBody($text), $status, $this->injectContentType('text/plain; charset=utf-8', $headers) ); } /** * Create the message body. * * @param string|StreamInterface $text * @return StreamInterface * @throws InvalidArgumentException if $html is neither a string or stream. */ private function createBody($text) { if ($text instanceof StreamInterface) { return $text; } if (! is_string($text)) { throw new InvalidArgumentException(sprintf( 'Invalid content (%s) provided to %s', (is_object($text) ? get_class($text) : gettype($text)), __CLASS__ )); } $body = new Stream('php://temp', 'wb+'); $body->write($text); $body->rewind(); return $body; } }