@@ -15,39 +15,39 @@ |
||
15 | 15 | */ |
16 | 16 | class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile |
17 | 17 | { |
18 | - /** |
|
19 | - * Create a new EmbeddedFile. |
|
20 | - * |
|
21 | - * Details may be optionally provided to the constructor. |
|
22 | - * |
|
23 | - * @param string|Swift_OutputByteStream $data |
|
24 | - * @param string $filename |
|
25 | - * @param string $contentType |
|
26 | - */ |
|
27 | - public function __construct($data = null, $filename = null, $contentType = null) |
|
28 | - { |
|
29 | - \call_user_func_array( |
|
30 | - [$this, 'Swift_Mime_EmbeddedFile::__construct'], |
|
31 | - Swift_DependencyContainer::getInstance() |
|
32 | - ->createDependenciesFor('mime.embeddedfile') |
|
33 | - ); |
|
18 | + /** |
|
19 | + * Create a new EmbeddedFile. |
|
20 | + * |
|
21 | + * Details may be optionally provided to the constructor. |
|
22 | + * |
|
23 | + * @param string|Swift_OutputByteStream $data |
|
24 | + * @param string $filename |
|
25 | + * @param string $contentType |
|
26 | + */ |
|
27 | + public function __construct($data = null, $filename = null, $contentType = null) |
|
28 | + { |
|
29 | + \call_user_func_array( |
|
30 | + [$this, 'Swift_Mime_EmbeddedFile::__construct'], |
|
31 | + Swift_DependencyContainer::getInstance() |
|
32 | + ->createDependenciesFor('mime.embeddedfile') |
|
33 | + ); |
|
34 | 34 | |
35 | - $this->setBody($data); |
|
36 | - $this->setFilename($filename); |
|
37 | - if ($contentType) { |
|
38 | - $this->setContentType($contentType); |
|
39 | - } |
|
40 | - } |
|
35 | + $this->setBody($data); |
|
36 | + $this->setFilename($filename); |
|
37 | + if ($contentType) { |
|
38 | + $this->setContentType($contentType); |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Create a new EmbeddedFile from a filesystem path. |
|
44 | - * |
|
45 | - * @param string $path |
|
46 | - * |
|
47 | - * @return Swift_Mime_EmbeddedFile |
|
48 | - */ |
|
49 | - public static function fromPath($path) |
|
50 | - { |
|
51 | - return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); |
|
52 | - } |
|
42 | + /** |
|
43 | + * Create a new EmbeddedFile from a filesystem path. |
|
44 | + * |
|
45 | + * @param string $path |
|
46 | + * |
|
47 | + * @return Swift_Mime_EmbeddedFile |
|
48 | + */ |
|
49 | + public static function fromPath($path) |
|
50 | + { |
|
51 | + return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); |
|
52 | + } |
|
53 | 53 | } |
@@ -15,84 +15,84 @@ |
||
15 | 15 | */ |
16 | 16 | class Swift_Mailer |
17 | 17 | { |
18 | - /** The Transport used to send messages */ |
|
19 | - private $transport; |
|
18 | + /** The Transport used to send messages */ |
|
19 | + private $transport; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Create a new Mailer using $transport for delivery. |
|
23 | - */ |
|
24 | - public function __construct(Swift_Transport $transport) |
|
25 | - { |
|
26 | - $this->transport = $transport; |
|
27 | - } |
|
21 | + /** |
|
22 | + * Create a new Mailer using $transport for delivery. |
|
23 | + */ |
|
24 | + public function __construct(Swift_Transport $transport) |
|
25 | + { |
|
26 | + $this->transport = $transport; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Create a new class instance of one of the message services. |
|
31 | - * |
|
32 | - * For example 'mimepart' would create a 'message.mimepart' instance |
|
33 | - * |
|
34 | - * @param string $service |
|
35 | - * |
|
36 | - * @return object |
|
37 | - */ |
|
38 | - public function createMessage($service = 'message') |
|
39 | - { |
|
40 | - return Swift_DependencyContainer::getInstance() |
|
41 | - ->lookup('message.'.$service); |
|
42 | - } |
|
29 | + /** |
|
30 | + * Create a new class instance of one of the message services. |
|
31 | + * |
|
32 | + * For example 'mimepart' would create a 'message.mimepart' instance |
|
33 | + * |
|
34 | + * @param string $service |
|
35 | + * |
|
36 | + * @return object |
|
37 | + */ |
|
38 | + public function createMessage($service = 'message') |
|
39 | + { |
|
40 | + return Swift_DependencyContainer::getInstance() |
|
41 | + ->lookup('message.'.$service); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Send the given Message like it would be sent in a mail client. |
|
46 | - * |
|
47 | - * All recipients (with the exception of Bcc) will be able to see the other |
|
48 | - * recipients this message was sent to. |
|
49 | - * |
|
50 | - * Recipient/sender data will be retrieved from the Message object. |
|
51 | - * |
|
52 | - * The return value is the number of recipients who were accepted for |
|
53 | - * delivery. |
|
54 | - * |
|
55 | - * @param array $failedRecipients An array of failures by-reference |
|
56 | - * |
|
57 | - * @return int The number of successful recipients. Can be 0 which indicates failure |
|
58 | - */ |
|
59 | - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) |
|
60 | - { |
|
61 | - $failedRecipients = (array) $failedRecipients; |
|
44 | + /** |
|
45 | + * Send the given Message like it would be sent in a mail client. |
|
46 | + * |
|
47 | + * All recipients (with the exception of Bcc) will be able to see the other |
|
48 | + * recipients this message was sent to. |
|
49 | + * |
|
50 | + * Recipient/sender data will be retrieved from the Message object. |
|
51 | + * |
|
52 | + * The return value is the number of recipients who were accepted for |
|
53 | + * delivery. |
|
54 | + * |
|
55 | + * @param array $failedRecipients An array of failures by-reference |
|
56 | + * |
|
57 | + * @return int The number of successful recipients. Can be 0 which indicates failure |
|
58 | + */ |
|
59 | + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) |
|
60 | + { |
|
61 | + $failedRecipients = (array) $failedRecipients; |
|
62 | 62 | |
63 | - // FIXME: to be removed in 7.0 (as transport must now start itself on send) |
|
64 | - if (!$this->transport->isStarted()) { |
|
65 | - $this->transport->start(); |
|
66 | - } |
|
63 | + // FIXME: to be removed in 7.0 (as transport must now start itself on send) |
|
64 | + if (!$this->transport->isStarted()) { |
|
65 | + $this->transport->start(); |
|
66 | + } |
|
67 | 67 | |
68 | - $sent = 0; |
|
68 | + $sent = 0; |
|
69 | 69 | |
70 | - try { |
|
71 | - $sent = $this->transport->send($message, $failedRecipients); |
|
72 | - } catch (Swift_RfcComplianceException $e) { |
|
73 | - foreach ($message->getTo() as $address => $name) { |
|
74 | - $failedRecipients[] = $address; |
|
75 | - } |
|
76 | - } |
|
70 | + try { |
|
71 | + $sent = $this->transport->send($message, $failedRecipients); |
|
72 | + } catch (Swift_RfcComplianceException $e) { |
|
73 | + foreach ($message->getTo() as $address => $name) { |
|
74 | + $failedRecipients[] = $address; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - return $sent; |
|
79 | - } |
|
78 | + return $sent; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Register a plugin using a known unique key (e.g. myPlugin). |
|
83 | - */ |
|
84 | - public function registerPlugin(Swift_Events_EventListener $plugin) |
|
85 | - { |
|
86 | - $this->transport->registerPlugin($plugin); |
|
87 | - } |
|
81 | + /** |
|
82 | + * Register a plugin using a known unique key (e.g. myPlugin). |
|
83 | + */ |
|
84 | + public function registerPlugin(Swift_Events_EventListener $plugin) |
|
85 | + { |
|
86 | + $this->transport->registerPlugin($plugin); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * The Transport used to send messages. |
|
91 | - * |
|
92 | - * @return Swift_Transport |
|
93 | - */ |
|
94 | - public function getTransport() |
|
95 | - { |
|
96 | - return $this->transport; |
|
97 | - } |
|
89 | + /** |
|
90 | + * The Transport used to send messages. |
|
91 | + * |
|
92 | + * @return Swift_Transport |
|
93 | + */ |
|
94 | + public function getTransport() |
|
95 | + { |
|
96 | + return $this->transport; |
|
97 | + } |
|
98 | 98 | } |
@@ -15,39 +15,39 @@ |
||
15 | 15 | */ |
16 | 16 | interface Swift_Spool |
17 | 17 | { |
18 | - /** |
|
19 | - * Starts this Spool mechanism. |
|
20 | - */ |
|
21 | - public function start(); |
|
18 | + /** |
|
19 | + * Starts this Spool mechanism. |
|
20 | + */ |
|
21 | + public function start(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * Stops this Spool mechanism. |
|
25 | - */ |
|
26 | - public function stop(); |
|
23 | + /** |
|
24 | + * Stops this Spool mechanism. |
|
25 | + */ |
|
26 | + public function stop(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Tests if this Spool mechanism has started. |
|
30 | - * |
|
31 | - * @return bool |
|
32 | - */ |
|
33 | - public function isStarted(); |
|
28 | + /** |
|
29 | + * Tests if this Spool mechanism has started. |
|
30 | + * |
|
31 | + * @return bool |
|
32 | + */ |
|
33 | + public function isStarted(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Queues a message. |
|
37 | - * |
|
38 | - * @param Swift_Mime_SimpleMessage $message The message to store |
|
39 | - * |
|
40 | - * @return bool Whether the operation has succeeded |
|
41 | - */ |
|
42 | - public function queueMessage(Swift_Mime_SimpleMessage $message); |
|
35 | + /** |
|
36 | + * Queues a message. |
|
37 | + * |
|
38 | + * @param Swift_Mime_SimpleMessage $message The message to store |
|
39 | + * |
|
40 | + * @return bool Whether the operation has succeeded |
|
41 | + */ |
|
42 | + public function queueMessage(Swift_Mime_SimpleMessage $message); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Sends messages using the given transport instance. |
|
46 | - * |
|
47 | - * @param Swift_Transport $transport A transport instance |
|
48 | - * @param string[] $failedRecipients An array of failures by-reference |
|
49 | - * |
|
50 | - * @return int The number of sent emails |
|
51 | - */ |
|
52 | - public function flushQueue(Swift_Transport $transport, &$failedRecipients = null); |
|
44 | + /** |
|
45 | + * Sends messages using the given transport instance. |
|
46 | + * |
|
47 | + * @param Swift_Transport $transport A transport instance |
|
48 | + * @param string[] $failedRecipients An array of failures by-reference |
|
49 | + * |
|
50 | + * @return int The number of sent emails |
|
51 | + */ |
|
52 | + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null); |
|
53 | 53 | } |
@@ -13,10 +13,10 @@ |
||
13 | 13 | */ |
14 | 14 | interface Swift_IdGenerator |
15 | 15 | { |
16 | - /** |
|
17 | - * Returns a globally unique string to use for Message-ID or Content-ID. |
|
18 | - * |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function generateId(); |
|
16 | + /** |
|
17 | + * Returns a globally unique string to use for Message-ID or Content-ID. |
|
18 | + * |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function generateId(); |
|
22 | 22 | } |
@@ -22,24 +22,24 @@ |
||
22 | 22 | */ |
23 | 23 | class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport |
24 | 24 | { |
25 | - /** |
|
26 | - * @param string $host |
|
27 | - * @param int $port |
|
28 | - * @param string|null $encryption SMTP encryption mode: |
|
29 | - * - null for plain SMTP (no encryption), |
|
30 | - * - 'tls' for SMTP with STARTTLS (best effort encryption), |
|
31 | - * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). |
|
32 | - */ |
|
33 | - public function __construct($host = 'localhost', $port = 25, $encryption = null) |
|
34 | - { |
|
35 | - \call_user_func_array( |
|
36 | - [$this, 'Swift_Transport_EsmtpTransport::__construct'], |
|
37 | - Swift_DependencyContainer::getInstance() |
|
38 | - ->createDependenciesFor('transport.smtp') |
|
39 | - ); |
|
25 | + /** |
|
26 | + * @param string $host |
|
27 | + * @param int $port |
|
28 | + * @param string|null $encryption SMTP encryption mode: |
|
29 | + * - null for plain SMTP (no encryption), |
|
30 | + * - 'tls' for SMTP with STARTTLS (best effort encryption), |
|
31 | + * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). |
|
32 | + */ |
|
33 | + public function __construct($host = 'localhost', $port = 25, $encryption = null) |
|
34 | + { |
|
35 | + \call_user_func_array( |
|
36 | + [$this, 'Swift_Transport_EsmtpTransport::__construct'], |
|
37 | + Swift_DependencyContainer::getInstance() |
|
38 | + ->createDependenciesFor('transport.smtp') |
|
39 | + ); |
|
40 | 40 | |
41 | - $this->setHost($host); |
|
42 | - $this->setPort($port); |
|
43 | - $this->setEncryption($encryption); |
|
44 | - } |
|
41 | + $this->setHost($host); |
|
42 | + $this->setPort($port); |
|
43 | + $this->setEncryption($encryption); |
|
44 | + } |
|
45 | 45 | } |
@@ -15,19 +15,19 @@ |
||
15 | 15 | */ |
16 | 16 | class Swift_SpoolTransport extends Swift_Transport_SpoolTransport |
17 | 17 | { |
18 | - /** |
|
19 | - * Create a new SpoolTransport. |
|
20 | - */ |
|
21 | - public function __construct(Swift_Spool $spool) |
|
22 | - { |
|
23 | - $arguments = Swift_DependencyContainer::getInstance() |
|
24 | - ->createDependenciesFor('transport.spool'); |
|
18 | + /** |
|
19 | + * Create a new SpoolTransport. |
|
20 | + */ |
|
21 | + public function __construct(Swift_Spool $spool) |
|
22 | + { |
|
23 | + $arguments = Swift_DependencyContainer::getInstance() |
|
24 | + ->createDependenciesFor('transport.spool'); |
|
25 | 25 | |
26 | - $arguments[] = $spool; |
|
26 | + $arguments[] = $spool; |
|
27 | 27 | |
28 | - \call_user_func_array( |
|
29 | - [$this, 'Swift_Transport_SpoolTransport::__construct'], |
|
30 | - $arguments |
|
31 | - ); |
|
32 | - } |
|
28 | + \call_user_func_array( |
|
29 | + [$this, 'Swift_Transport_SpoolTransport::__construct'], |
|
30 | + $arguments |
|
31 | + ); |
|
32 | + } |
|
33 | 33 | } |
@@ -16,52 +16,52 @@ |
||
16 | 16 | */ |
17 | 17 | interface Swift_CharacterReader |
18 | 18 | { |
19 | - const MAP_TYPE_INVALID = 0x01; |
|
20 | - const MAP_TYPE_FIXED_LEN = 0x02; |
|
21 | - const MAP_TYPE_POSITIONS = 0x03; |
|
19 | + const MAP_TYPE_INVALID = 0x01; |
|
20 | + const MAP_TYPE_FIXED_LEN = 0x02; |
|
21 | + const MAP_TYPE_POSITIONS = 0x03; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Returns the complete character map. |
|
25 | - * |
|
26 | - * @param string $string |
|
27 | - * @param int $startOffset |
|
28 | - * @param array $currentMap |
|
29 | - * @param mixed $ignoredChars |
|
30 | - * |
|
31 | - * @return int |
|
32 | - */ |
|
33 | - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars); |
|
23 | + /** |
|
24 | + * Returns the complete character map. |
|
25 | + * |
|
26 | + * @param string $string |
|
27 | + * @param int $startOffset |
|
28 | + * @param array $currentMap |
|
29 | + * @param mixed $ignoredChars |
|
30 | + * |
|
31 | + * @return int |
|
32 | + */ |
|
33 | + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Returns the mapType, see constants. |
|
37 | - * |
|
38 | - * @return int |
|
39 | - */ |
|
40 | - public function getMapType(); |
|
35 | + /** |
|
36 | + * Returns the mapType, see constants. |
|
37 | + * |
|
38 | + * @return int |
|
39 | + */ |
|
40 | + public function getMapType(); |
|
41 | 41 | |
42 | - /** |
|
43 | - * Returns an integer which specifies how many more bytes to read. |
|
44 | - * |
|
45 | - * A positive integer indicates the number of more bytes to fetch before invoking |
|
46 | - * this method again. |
|
47 | - * |
|
48 | - * A value of zero means this is already a valid character. |
|
49 | - * A value of -1 means this cannot possibly be a valid character. |
|
50 | - * |
|
51 | - * @param int[] $bytes |
|
52 | - * @param int $size |
|
53 | - * |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public function validateByteSequence($bytes, $size); |
|
42 | + /** |
|
43 | + * Returns an integer which specifies how many more bytes to read. |
|
44 | + * |
|
45 | + * A positive integer indicates the number of more bytes to fetch before invoking |
|
46 | + * this method again. |
|
47 | + * |
|
48 | + * A value of zero means this is already a valid character. |
|
49 | + * A value of -1 means this cannot possibly be a valid character. |
|
50 | + * |
|
51 | + * @param int[] $bytes |
|
52 | + * @param int $size |
|
53 | + * |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public function validateByteSequence($bytes, $size); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Returns the number of bytes which should be read to start each character. |
|
60 | - * |
|
61 | - * For fixed width character sets this should be the number of octets-per-character. |
|
62 | - * For multibyte character sets this will probably be 1. |
|
63 | - * |
|
64 | - * @return int |
|
65 | - */ |
|
66 | - public function getInitialByteSize(); |
|
58 | + /** |
|
59 | + * Returns the number of bytes which should be read to start each character. |
|
60 | + * |
|
61 | + * For fixed width character sets this should be the number of octets-per-character. |
|
62 | + * For multibyte character sets this will probably be 1. |
|
63 | + * |
|
64 | + * @return int |
|
65 | + */ |
|
66 | + public function getInitialByteSize(); |
|
67 | 67 | } |
@@ -15,140 +15,140 @@ |
||
15 | 15 | */ |
16 | 16 | class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_InputByteStream |
17 | 17 | { |
18 | - /** |
|
19 | - * The outgoing traffic counter. |
|
20 | - * |
|
21 | - * @var int |
|
22 | - */ |
|
23 | - private $out = 0; |
|
24 | - |
|
25 | - /** |
|
26 | - * The incoming traffic counter. |
|
27 | - * |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - private $in = 0; |
|
31 | - |
|
32 | - /** Bound byte streams */ |
|
33 | - private $mirrors = []; |
|
34 | - |
|
35 | - /** |
|
36 | - * Not used. |
|
37 | - */ |
|
38 | - public function beforeSendPerformed(Swift_Events_SendEvent $evt) |
|
39 | - { |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Invoked immediately after the Message is sent. |
|
44 | - */ |
|
45 | - public function sendPerformed(Swift_Events_SendEvent $evt) |
|
46 | - { |
|
47 | - $message = $evt->getMessage(); |
|
48 | - $message->toByteStream($this); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Invoked immediately following a command being sent. |
|
53 | - */ |
|
54 | - public function commandSent(Swift_Events_CommandEvent $evt) |
|
55 | - { |
|
56 | - $command = $evt->getCommand(); |
|
57 | - $this->out += \strlen($command); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Invoked immediately following a response coming back. |
|
62 | - */ |
|
63 | - public function responseReceived(Swift_Events_ResponseEvent $evt) |
|
64 | - { |
|
65 | - $response = $evt->getResponse(); |
|
66 | - $this->in += \strlen($response); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Called when a message is sent so that the outgoing counter can be increased. |
|
71 | - * |
|
72 | - * @param string $bytes |
|
73 | - */ |
|
74 | - public function write($bytes) |
|
75 | - { |
|
76 | - $this->out += \strlen($bytes); |
|
77 | - foreach ($this->mirrors as $stream) { |
|
78 | - $stream->write($bytes); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Not used. |
|
84 | - */ |
|
85 | - public function commit() |
|
86 | - { |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Attach $is to this stream. |
|
91 | - * |
|
92 | - * The stream acts as an observer, receiving all data that is written. |
|
93 | - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. |
|
94 | - */ |
|
95 | - public function bind(Swift_InputByteStream $is) |
|
96 | - { |
|
97 | - $this->mirrors[] = $is; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Remove an already bound stream. |
|
102 | - * |
|
103 | - * If $is is not bound, no errors will be raised. |
|
104 | - * If the stream currently has any buffered data it will be written to $is |
|
105 | - * before unbinding occurs. |
|
106 | - */ |
|
107 | - public function unbind(Swift_InputByteStream $is) |
|
108 | - { |
|
109 | - foreach ($this->mirrors as $k => $stream) { |
|
110 | - if ($is === $stream) { |
|
111 | - unset($this->mirrors[$k]); |
|
112 | - } |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Not used. |
|
118 | - */ |
|
119 | - public function flushBuffers() |
|
120 | - { |
|
121 | - foreach ($this->mirrors as $stream) { |
|
122 | - $stream->flushBuffers(); |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Get the total number of bytes sent to the server. |
|
128 | - * |
|
129 | - * @return int |
|
130 | - */ |
|
131 | - public function getBytesOut() |
|
132 | - { |
|
133 | - return $this->out; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Get the total number of bytes received from the server. |
|
138 | - * |
|
139 | - * @return int |
|
140 | - */ |
|
141 | - public function getBytesIn() |
|
142 | - { |
|
143 | - return $this->in; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Reset the internal counters to zero. |
|
148 | - */ |
|
149 | - public function reset() |
|
150 | - { |
|
151 | - $this->out = 0; |
|
152 | - $this->in = 0; |
|
153 | - } |
|
18 | + /** |
|
19 | + * The outgoing traffic counter. |
|
20 | + * |
|
21 | + * @var int |
|
22 | + */ |
|
23 | + private $out = 0; |
|
24 | + |
|
25 | + /** |
|
26 | + * The incoming traffic counter. |
|
27 | + * |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + private $in = 0; |
|
31 | + |
|
32 | + /** Bound byte streams */ |
|
33 | + private $mirrors = []; |
|
34 | + |
|
35 | + /** |
|
36 | + * Not used. |
|
37 | + */ |
|
38 | + public function beforeSendPerformed(Swift_Events_SendEvent $evt) |
|
39 | + { |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Invoked immediately after the Message is sent. |
|
44 | + */ |
|
45 | + public function sendPerformed(Swift_Events_SendEvent $evt) |
|
46 | + { |
|
47 | + $message = $evt->getMessage(); |
|
48 | + $message->toByteStream($this); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Invoked immediately following a command being sent. |
|
53 | + */ |
|
54 | + public function commandSent(Swift_Events_CommandEvent $evt) |
|
55 | + { |
|
56 | + $command = $evt->getCommand(); |
|
57 | + $this->out += \strlen($command); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Invoked immediately following a response coming back. |
|
62 | + */ |
|
63 | + public function responseReceived(Swift_Events_ResponseEvent $evt) |
|
64 | + { |
|
65 | + $response = $evt->getResponse(); |
|
66 | + $this->in += \strlen($response); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Called when a message is sent so that the outgoing counter can be increased. |
|
71 | + * |
|
72 | + * @param string $bytes |
|
73 | + */ |
|
74 | + public function write($bytes) |
|
75 | + { |
|
76 | + $this->out += \strlen($bytes); |
|
77 | + foreach ($this->mirrors as $stream) { |
|
78 | + $stream->write($bytes); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Not used. |
|
84 | + */ |
|
85 | + public function commit() |
|
86 | + { |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Attach $is to this stream. |
|
91 | + * |
|
92 | + * The stream acts as an observer, receiving all data that is written. |
|
93 | + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. |
|
94 | + */ |
|
95 | + public function bind(Swift_InputByteStream $is) |
|
96 | + { |
|
97 | + $this->mirrors[] = $is; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Remove an already bound stream. |
|
102 | + * |
|
103 | + * If $is is not bound, no errors will be raised. |
|
104 | + * If the stream currently has any buffered data it will be written to $is |
|
105 | + * before unbinding occurs. |
|
106 | + */ |
|
107 | + public function unbind(Swift_InputByteStream $is) |
|
108 | + { |
|
109 | + foreach ($this->mirrors as $k => $stream) { |
|
110 | + if ($is === $stream) { |
|
111 | + unset($this->mirrors[$k]); |
|
112 | + } |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Not used. |
|
118 | + */ |
|
119 | + public function flushBuffers() |
|
120 | + { |
|
121 | + foreach ($this->mirrors as $stream) { |
|
122 | + $stream->flushBuffers(); |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Get the total number of bytes sent to the server. |
|
128 | + * |
|
129 | + * @return int |
|
130 | + */ |
|
131 | + public function getBytesOut() |
|
132 | + { |
|
133 | + return $this->out; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Get the total number of bytes received from the server. |
|
138 | + * |
|
139 | + * @return int |
|
140 | + */ |
|
141 | + public function getBytesIn() |
|
142 | + { |
|
143 | + return $this->in; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Reset the internal counters to zero. |
|
148 | + */ |
|
149 | + public function reset() |
|
150 | + { |
|
151 | + $this->out = 0; |
|
152 | + $this->in = 0; |
|
153 | + } |
|
154 | 154 | } |
@@ -15,56 +15,56 @@ |
||
15 | 15 | */ |
16 | 16 | class Swift_Plugins_MessageLogger implements Swift_Events_SendListener |
17 | 17 | { |
18 | - /** |
|
19 | - * @var Swift_Mime_SimpleMessage[] |
|
20 | - */ |
|
21 | - private $messages; |
|
18 | + /** |
|
19 | + * @var Swift_Mime_SimpleMessage[] |
|
20 | + */ |
|
21 | + private $messages; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->messages = []; |
|
26 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->messages = []; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Get the message list. |
|
30 | - * |
|
31 | - * @return Swift_Mime_SimpleMessage[] |
|
32 | - */ |
|
33 | - public function getMessages() |
|
34 | - { |
|
35 | - return $this->messages; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Get the message list. |
|
30 | + * |
|
31 | + * @return Swift_Mime_SimpleMessage[] |
|
32 | + */ |
|
33 | + public function getMessages() |
|
34 | + { |
|
35 | + return $this->messages; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the message count. |
|
40 | - * |
|
41 | - * @return int count |
|
42 | - */ |
|
43 | - public function countMessages() |
|
44 | - { |
|
45 | - return \count($this->messages); |
|
46 | - } |
|
38 | + /** |
|
39 | + * Get the message count. |
|
40 | + * |
|
41 | + * @return int count |
|
42 | + */ |
|
43 | + public function countMessages() |
|
44 | + { |
|
45 | + return \count($this->messages); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Empty the message list. |
|
50 | - */ |
|
51 | - public function clear() |
|
52 | - { |
|
53 | - $this->messages = []; |
|
54 | - } |
|
48 | + /** |
|
49 | + * Empty the message list. |
|
50 | + */ |
|
51 | + public function clear() |
|
52 | + { |
|
53 | + $this->messages = []; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Invoked immediately before the Message is sent. |
|
58 | - */ |
|
59 | - public function beforeSendPerformed(Swift_Events_SendEvent $evt) |
|
60 | - { |
|
61 | - $this->messages[] = clone $evt->getMessage(); |
|
62 | - } |
|
56 | + /** |
|
57 | + * Invoked immediately before the Message is sent. |
|
58 | + */ |
|
59 | + public function beforeSendPerformed(Swift_Events_SendEvent $evt) |
|
60 | + { |
|
61 | + $this->messages[] = clone $evt->getMessage(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Invoked immediately after the Message is sent. |
|
66 | - */ |
|
67 | - public function sendPerformed(Swift_Events_SendEvent $evt) |
|
68 | - { |
|
69 | - } |
|
64 | + /** |
|
65 | + * Invoked immediately after the Message is sent. |
|
66 | + */ |
|
67 | + public function sendPerformed(Swift_Events_SendEvent $evt) |
|
68 | + { |
|
69 | + } |
|
70 | 70 | } |