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