🔧
This commit is contained in:
32
vendor/symfony/mime/RawMessage.php
vendored
32
vendor/symfony/mime/RawMessage.php
vendored
@@ -18,20 +18,35 @@ use Symfony\Component\Mime\Exception\LogicException;
|
||||
*/
|
||||
class RawMessage
|
||||
{
|
||||
private iterable|string|null $message = null;
|
||||
/** @var iterable<string>|string|resource */
|
||||
private $message;
|
||||
private bool $isGeneratorClosed;
|
||||
|
||||
public function __construct(iterable|string $message)
|
||||
/**
|
||||
* @param iterable<string>|string|resource $message
|
||||
*/
|
||||
public function __construct(mixed $message)
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (\is_resource($this->message)) {
|
||||
fclose($this->message);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
if (\is_string($this->message)) {
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
if (\is_resource($this->message)) {
|
||||
return stream_get_contents($this->message, -1, 0);
|
||||
}
|
||||
|
||||
$message = '';
|
||||
foreach ($this->message as $chunk) {
|
||||
$message .= $chunk;
|
||||
@@ -53,10 +68,19 @@ class RawMessage
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_resource($this->message)) {
|
||||
rewind($this->message);
|
||||
while ($line = fgets($this->message)) {
|
||||
yield $line;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->message instanceof \Generator) {
|
||||
$message = '';
|
||||
$message = fopen('php://temp', 'w+');
|
||||
foreach ($this->message as $chunk) {
|
||||
$message .= $chunk;
|
||||
fwrite($message, $chunk);
|
||||
yield $chunk;
|
||||
}
|
||||
$this->isGeneratorClosed = !$this->message->valid();
|
||||
|
||||
Reference in New Issue
Block a user