$str .= "{
$key}: {
$value}\r\n";
} return "--{
$this->boundary
}\r\n".
trim($str)."\r\n\r\n";
} /**
* Create the aggregate stream that will be used to upload the POST data
*/
protected function createStream(array
$elements =
[]): StreamInterface
{ $stream =
new AppendStream();
foreach ($elements as $element) { if (!
is_array($element)) { throw new \
UnexpectedValueException('An array is expected'
);
} $this->
addElement($stream,
$element);
} // Add the trailing boundary with CRLF
$stream->
addStream(Utils::
streamFor("--{
$this->boundary
}--\r\n"
));