29 public function __construct($body,
string $type,
string $subtype, array $parameters)
31 parent::__construct();
33 if (!\is_string($body) && !is_iterable($body)) {
34 throw new \TypeError(sprintf(
'The body of "%s" must be a string or a iterable (got "%s").', self::class, \is_object($body) ? \get_class($body) : \gettype($body)));
39 $this->subtype = $subtype;
40 $this->parameters = $parameters;
50 return $this->subtype;
55 if (\is_string($this->body)) {
60 foreach ($this->body as $chunk) {
70 if (\is_string($this->body)) {
77 foreach ($this->body as $chunk) {
86 $headers = clone parent::getHeaders();
90 foreach ($this->parameters as $name => $value) {
91 $headers->setHeaderParameter(
'Content-Type', $name, $value);
100 if (is_iterable($this->body)) {
106 return [
'_headers',
'body',
'type',
'subtype',
'parameters'];
111 $r = new \ReflectionProperty(AbstractPart::class,
'headers');
112 $r->setAccessible(
true);
113 $r->setValue($this, $this->_headers);
114 unset($this->_headers);