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