26 parent::__construct();
28 foreach ($parts as $part) {
29 $this->parts[] = $part;
48 $headers = parent::getPreparedHeaders();
49 $headers->setHeaderParameter(
'Content-Type',
'boundary', $this->getBoundary());
58 foreach ($parts as $part) {
59 $string .=
'--'.$this->getBoundary().
"\r\n".$part->toString().
"\r\n";
61 $string .=
'--'.$this->getBoundary().
"--\r\n";
69 foreach ($parts as $part) {
70 yield
'--'.$this->getBoundary().
"\r\n";
71 yield from $part->toIterable();
74 yield
'--'.$this->getBoundary().
"--\r\n";
79 $str = parent::asDebugString();
80 foreach ($this->
getParts() as $part) {
81 $lines = explode(
"\n", $part->asDebugString());
82 $str .=
"\n └ ".array_shift($lines);
83 foreach ($lines as $line) {
91 private function getBoundary(): string
93 if (
null === $this->boundary) {
94 $this->boundary = strtr(base64_encode(random_bytes(6)),
'+/',
'-_');
97 return $this->boundary;