Skip to content

Commit e451466

Browse files
committed
Add MultipartStreamBuilder::addData
* Added a public method addData for manipulating the private $data array properly.
1 parent 121299c commit e451466

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/MultipartStreamBuilder.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ public function __construct($streamFactory = null)
7272
}
7373
}
7474

75+
/**
76+
* Add a resource to the Multipart Stream
77+
*
78+
* @param string|resource|\Psr\Http\Message\StreamInterface $resource
79+
* The filepath, resource or StreamInterface of the data.
80+
* @param array $headers
81+
* Additional headers array: ['header-name' => 'header-value'].
82+
*
83+
* @return MultipartStreamBuilder
84+
*/
85+
public function addData($resource, array $headers = [])
86+
{
87+
$stream = $this->createStream($resource);
88+
$this->data[] = ['contents' => $stream, 'headers' => $headers];
89+
return $this;
90+
}
91+
7592
/**
7693
* Add a resource to the Multipart Stream.
7794
*

0 commit comments

Comments
 (0)