PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / symfony / mime / RawMessage.php

RawMessage.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/symfony/mime/RawMessage.php

95 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Mime;
13
14 use Symfony\Component\Mime\Exception\LogicException;
15
16 /**
17 * @author Fabien Potencier <fabien@symfony.com>
18 */
19 class RawMessage implements \Serializable
20 {
21 /**
22 * @var iterable|string
23 */
24 private $message;
25
26 /**
27 * @param iterable|string $message
28 */
29 public function __construct($message)
30 {
31 $this->message = $message;
32 }
33
34 public function toString(): string
35 {
36 if (\is_string($this->message)) {
37 return $this->message;
38 }
39 if ($this->message instanceof \Traversable) {
40 $this->message = iterator_to_array($this->message, false);
41 }
42
43 return $this->message = implode('', $this->message);
44 }
45
46 public function toIterable(): iterable
47 {
48 if (\is_string($this->message)) {
49 yield $this->message;
50
51 return;
52 }
53
54 $message = '';
55 foreach ($this->message as $chunk) {
56 $message .= $chunk;
57 yield $chunk;
58 }
59 $this->message = $message;
60 }
61
62 /**
63 * @throws LogicException if the message is not valid
64 */
65 public function ensureValidity()
66 {
67 }
68
69 /**
70 * @internal
71 */
72 final public function serialize(): string
73 {
74 return serialize($this->__serialize());
75 }
76
77 /**
78 * @internal
79 */
80 final public function unserialize($serialized)
81 {
82 $this->__unserialize(unserialize($serialized));
83 }
84
85 public function __serialize(): array
86 {
87 return [$this->toString()];
88 }
89
90 public function __unserialize(array $data): void
91 {
92 [$this->message] = $data;
93 }
94 }
95