refactor: mail interfaces
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -19,422 +19,9 @@ use DateTimeImmutable;
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
abstract class MessagePropertiesMutableAbstract extends MessagePropertiesBaseAbstract implements MessagePropertiesMutableInterface {
|
||||
|
||||
public const JSON_TYPE = MessagePropertiesBaseInterface::JSON_TYPE;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setHeaders(array $value): static {
|
||||
$this->data['headers'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setHeader(string $name, string|array $value): static {
|
||||
$this->data['headers'][$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUrid(?string $value): static {
|
||||
$this->data['urid'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCreated(DateTimeImmutable $value): static {
|
||||
$this->data['created'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setModified(DateTimeImmutable $value): static {
|
||||
$this->data['modified'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setDate(DateTimeImmutable $value): static {
|
||||
$this->data['date'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReceived(?DateTimeImmutable $value): static {
|
||||
$this->data['received'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSize(?int $value): static {
|
||||
$this->data['size'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSender(?AddressInterface $value): static {
|
||||
$this->data['sender'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFrom(AddressInterface $value): static {
|
||||
$this->data['from'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReplyTo(AddressInterface ...$value): static {
|
||||
$this->data['replyTo'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTo(AddressInterface ...$value): static {
|
||||
$this->data['to'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCc(AddressInterface ...$value): static {
|
||||
$this->data['cc'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBcc(AddressInterface ...$value): static {
|
||||
$this->data['bcc'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setInReplyTo(?string $value): static {
|
||||
$this->data['inReplyTo'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReferences(string ...$value): static {
|
||||
$this->data['references'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSubject(string $value): static {
|
||||
$this->data['subject'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSnippet(?string $value): static {
|
||||
$this->data['snippet'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBodyText(?string $value): static {
|
||||
$this->data['bodyText'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the plain text body charset
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setBodyTextCharset(string $value): static {
|
||||
$this->data['bodyTextCharset'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the plain text body size
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setBodyTextSize(int $value): static {
|
||||
$this->data['bodyTextSize'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBodyHtml(?string $value): static {
|
||||
$this->data['bodyHtml'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTML body charset
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setBodyHtmlCharset(string $value): static {
|
||||
$this->data['bodyHtmlCharset'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTML body size
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setBodyHtmlSize(int $value): static {
|
||||
$this->data['bodyHtmlSize'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setAttachments(AttachmentInterface ...$value): static {
|
||||
$this->data['attachments'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addAttachment(AttachmentInterface $value): static {
|
||||
$this->data['attachments'][] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message flags
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setFlags(array $value): static {
|
||||
if (!isset($this->data['flags'])) {
|
||||
$this->data['flags'] = [
|
||||
'read' => false,
|
||||
'starred' => false,
|
||||
'important' => false,
|
||||
'answered' => false,
|
||||
'forwarded' => false,
|
||||
'draft' => false,
|
||||
'deleted' => false,
|
||||
'flagged' => false,
|
||||
];
|
||||
}
|
||||
$this->data['flags'] = array_merge($this->data['flags'], $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFlag(string $name, bool $value): static {
|
||||
if (!isset($this->data['flags'])) {
|
||||
$this->data['flags'] = [
|
||||
'read' => false,
|
||||
'starred' => false,
|
||||
'important' => false,
|
||||
'answered' => false,
|
||||
'forwarded' => false,
|
||||
'draft' => false,
|
||||
'deleted' => false,
|
||||
'flagged' => false,
|
||||
];
|
||||
}
|
||||
if (array_key_exists($name, $this->data['flags'])) {
|
||||
$this->data['flags'][$name] = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message labels
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string ...$value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setLabels(string ...$value): static {
|
||||
$this->data['labels'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message label
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function addLabel(string $value): static {
|
||||
$this->data['labels'][] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message tags
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string ...$value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setTags(string ...$value): static {
|
||||
$this->data['tags'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message tag
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function addTag(string $value): static {
|
||||
$this->data['tags'][] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message priority
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setPriority(string $value): static {
|
||||
$this->data['priority'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message sensitivity
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setSensitivity(string $value): static {
|
||||
$this->data['sensitivity'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets encryption information
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setEncryption(array $value): static {
|
||||
if (!isset($this->data['encryption'])) {
|
||||
$this->data['encryption'] = [
|
||||
'method' => null,
|
||||
'signed' => false,
|
||||
'encrypted' => false,
|
||||
];
|
||||
}
|
||||
$this->data['encryption'] = array_merge($this->data['encryption'], $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets delivery receipt flag
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setDeliveryReceipt(bool $value): static {
|
||||
$this->data['deliveryReceipt'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets read receipt flag
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setReadReceipt(bool $value): static {
|
||||
$this->data['readReceipt'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected string $type = 'mail.message';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -452,4 +39,213 @@ abstract class MessagePropertiesMutableAbstract extends MessagePropertiesBaseAbs
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSize(?int $value): static {
|
||||
$this->data[static::PROPERTY_SIZE] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setHeaders(array $value): static {
|
||||
$this->data[static::PROPERTY_HEADERS] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setHeader(string $name, string|array $value): static {
|
||||
$this->data[static::PROPERTY_HEADERS][$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUrid(?string $value): static {
|
||||
$this->data[static::PROPERTY_URID] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setInReplyTo(?string $value): static {
|
||||
$this->data[static::PROPERTY_IN_REPLY_TO] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReferences(string ...$value): static {
|
||||
$this->data[static::PROPERTY_REFERENCES] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReceived(?DateTimeImmutable $value): static {
|
||||
$this->data[static::PROPERTY_RECEIVED] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSent(DateTimeImmutable $value): static {
|
||||
$this->data[static::PROPERTY_SENT] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSender(?AddressInterface $value): static {
|
||||
$this->data[static::PROPERTY_SENDER] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFrom(AddressInterface $value): static {
|
||||
$this->data[static::PROPERTY_FROM] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReplyTo(AddressInterface ...$value): static {
|
||||
$this->data[static::PROPERTY_REPLY_TO] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTo(AddressInterface ...$value): static {
|
||||
$this->data[static::PROPERTY_TO] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCc(AddressInterface ...$value): static {
|
||||
$this->data[static::PROPERTY_CC] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBcc(AddressInterface ...$value): static {
|
||||
$this->data[static::PROPERTY_BCC] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSubject(string $value): static {
|
||||
$this->data[static::PROPERTY_SUBJECT] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBody(?MessagePartInterface $value): static {
|
||||
$this->data[static::PROPERTY_BODY] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBodyTextPlain(?string $value): static {
|
||||
$this->data[static::PROPERTY_BODY_TEXT_PLAIN] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setBodyTextHtml(?string $value): static {
|
||||
$this->data[static::PROPERTY_BODY_TEXT_HTML] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setAttachments(AttachmentInterface ...$value): static {
|
||||
$this->data[static::PROPERTY_ATTACHMENTS] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addAttachment(AttachmentInterface $value): static {
|
||||
$this->data[static::PROPERTY_ATTACHMENTS][] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message flags
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setFlags(array $value): static {
|
||||
if (!isset($this->data[static::PROPERTY_FLAGS])) {
|
||||
$this->data[static::PROPERTY_FLAGS] = [
|
||||
'read' => false,
|
||||
'starred' => false,
|
||||
'important' => false,
|
||||
'answered' => false,
|
||||
'forwarded' => false,
|
||||
'draft' => false,
|
||||
'deleted' => false,
|
||||
'flagged' => false,
|
||||
];
|
||||
}
|
||||
$this->data[static::PROPERTY_FLAGS] = array_merge($this->data[static::PROPERTY_FLAGS], $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFlag(string $name, bool $value): static {
|
||||
if (!isset($this->data[static::PROPERTY_FLAGS])) {
|
||||
$this->data[static::PROPERTY_FLAGS] = [
|
||||
'read' => false,
|
||||
'starred' => false,
|
||||
'important' => false,
|
||||
'answered' => false,
|
||||
'forwarded' => false,
|
||||
'draft' => false,
|
||||
'deleted' => false,
|
||||
'flagged' => false,
|
||||
];
|
||||
}
|
||||
if (array_key_exists($name, $this->data[static::PROPERTY_FLAGS])) {
|
||||
$this->data[static::PROPERTY_FLAGS][$name] = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user