src/Viserio/Component/Http/Stream/MultipartStream.php
private function addElement(AppendStream $stream, array $element): void
    {
        foreach (['contents', 'name'] as $key) {
            if (! \array_key_exists($key, $element)) {
                throw new InvalidArgumentException(\sprintf('A [%s] key is required', $key));
            }
        }

        $element['contents'] = Util::createStreamFor($element['contents']);

        if (empty($element['filename'])) {
            $uri = $element['contents']->getMetadata('uri');

            if (\substr($uri, 0, 6) !== 'php://') {
                $element['filename'] = $uri;
            }
        }

        [$body, $headers] = $this->createElement(
            $element['name'],
            $element['contents'],
            $element['filename'] ?? null,
            $element['headers'] ?? []
        );

        $stream->addStream(Util::createStreamFor($this->getHeaders($headers)));
        $stream->addStream($body);
        $stream->addStream(Util::createStreamFor("\r\n"));
    }
private function addElement(AppendStream $stream, array $element): void
    {
        foreach (['contents', 'name'] as $key) {
            if (! \array_key_exists($key, $element)) {
                throw new InvalidArgumentException(\sprintf('A [%s] key is required', $key));
            }
        }

        $element['contents'] = Util::createStreamFor($element['contents']);

        if (empty($element['filename'])) {
            $uri = $element['contents']->getMetadata('uri');

            if (\substr($uri, 0, 6) !== 'php://') {
                $element['filename'] = $uri;
            }
        }

        [$body, $headers] = $this->createElement(
            $element['name'],
            $element['contents'],
            $element['filename'] ?? null,
            $element['headers'] ?? []
        );

        $stream->addStream(Util::createStreamFor($this->getHeaders($headers)));
        $stream->addStream($body);
        $stream->addStream(Util::createStreamFor("\r\n"));
    }
@param AppendStream $stream
@param array        $element

@return void