You are here

private function MultipartStream::addElement in Auth0 Single Sign On 8.2

1 call to MultipartStream::addElement()
MultipartStream::createStream in vendor/guzzlehttp/psr7/src/MultipartStream.php
Create the aggregate stream that will be used to upload the POST data

File

vendor/guzzlehttp/psr7/src/MultipartStream.php, line 79

Class

MultipartStream
Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.

Namespace

GuzzleHttp\Psr7

Code

private function addElement(AppendStream $stream, array $element) {
  foreach ([
    'contents',
    'name',
  ] as $key) {
    if (!array_key_exists($key, $element)) {
      throw new \InvalidArgumentException("A '{$key}' key is required");
    }
  }
  $element['contents'] = stream_for($element['contents']);
  if (empty($element['filename'])) {
    $uri = $element['contents']
      ->getMetadata('uri');
    if (substr($uri, 0, 6) !== 'php://') {
      $element['filename'] = $uri;
    }
  }
  list($body, $headers) = $this
    ->createElement($element['name'], $element['contents'], isset($element['filename']) ? $element['filename'] : null, isset($element['headers']) ? $element['headers'] : []);
  $stream
    ->addStream(stream_for($this
    ->getHeaders($headers)));
  $stream
    ->addStream($body);
  $stream
    ->addStream(stream_for("\r\n"));
}