<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Object;
/** @var string */
private $subject;
- /** @var string */
+ /** @var string|null */
private $msgHtml;
/** @var string */
private $msgText;
}
/**
- * Returns the current email with a new recipient
- *
- * @param string $email The email of the recipient
- * @param int $uid The (optional) UID of the recipient for further infos
- *
- * @return static
+ * {@inheritDoc}
*/
- public function withRecipient(string $email, int $uid = null)
+ public function withRecipient(string $address, int $uid = null)
{
$newEmail = clone $this;
- $newEmail->toAddress = $email;
+ $newEmail->toAddress = $address;
$newEmail->toUid = $uid;
return $newEmail;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function withMessage(string $plaintext, string $html = null)
+ {
+ $newMail = clone $this;
+ $newMail->msgText = $plaintext;
+ $newMail->msgHtml = $html;
+
+ return $newMail;
+ }
+
+ /**
+ * Returns the properties of the email as an array
+ *
+ * @return array
+ */
+ private function toArray()
+ {
+ return get_object_vars($this);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function __toString()
+ {
+ return json_encode($this->toArray());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function jsonSerialize()
+ {
+ return $this->toArray();
+ }
}