Skip to content

Commit

Permalink
Adds same object return annotations.
Browse files Browse the repository at this point in the history
Based on: nextcloud#38987 (comment)

Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Faraz Samapoor <fsa@adlas.at>
  • Loading branch information
2 people authored and artonge committed Jun 27, 2023
1 parent 4cfab4b commit a449bd1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/private/Mail/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(
}

/**
* @return $this
* @since 13.0.0
*/
public function setFilename(string $filename): IAttachment {
Expand All @@ -53,6 +54,7 @@ public function setFilename(string $filename): IAttachment {
}

/**
* @return $this
* @since 13.0.0
*/
public function setContentType(string $contentType): IAttachment {
Expand All @@ -61,6 +63,7 @@ public function setContentType(string $contentType): IAttachment {
}

/**
* @return $this
* @since 13.0.0
*/
public function setBody(string $body): IAttachment {
Expand Down
21 changes: 21 additions & 0 deletions lib/private/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function __construct(

/**
* @since 13.0.0
* @return $this
*/
public function attach(IAttachment $attachment): IMessage {
/** @var Attachment $attachment */
Expand Down Expand Up @@ -114,6 +115,7 @@ protected function convertAddresses(array $addresses): array {
* If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php
*
* @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
public function setFrom(array $addresses): IMessage {
$this->from = $addresses;
Expand All @@ -129,6 +131,7 @@ public function getFrom(): array {

/**
* Set the Reply-To address of this message
* @return $this
*/
public function setReplyTo(array $addresses): IMessage {
$this->replyTo = $addresses;
Expand All @@ -146,6 +149,7 @@ public function getReplyTo(): array {
* Set the to addresses of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
public function setTo(array $recipients): IMessage {
$this->to = $recipients;
Expand All @@ -163,6 +167,7 @@ public function getTo(): array {
* Set the CC recipients of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
public function setCc(array $recipients): IMessage {
$this->cc = $recipients;
Expand All @@ -180,6 +185,7 @@ public function getCc(): array {
* Set the BCC recipients of this message.
*
* @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
* @return $this
*/
public function setBcc(array $recipients): IMessage {
$this->bcc = $recipients;
Expand All @@ -193,6 +199,9 @@ public function getBcc(): array {
return $this->bcc;
}

/**
* @return $this
*/
public function setSubject(string $subject): IMessage {
$this->symfonyEmail->subject($subject);
return $this;
Expand All @@ -205,6 +214,9 @@ public function getSubject(): string {
return $this->symfonyEmail->getSubject() ?? '';
}

/**
* @return $this
*/
public function setPlainBody(string $body): IMessage {
$this->symfonyEmail->text($body);
return $this;
Expand All @@ -219,6 +231,9 @@ public function getPlainBody(): string {
return $body;
}

/**
* @return $this
*/
public function setHtmlBody(string $body): IMessage {
if (!$this->plainTextOnly) {
$this->symfonyEmail->html($body);
Expand All @@ -240,6 +255,9 @@ public function getSymfonyEmail(): Email {
return $this->symfonyEmail;
}

/**
* @return $this
*/
public function setBody(string $body, string $contentType): IMessage {
if (!$this->plainTextOnly || $contentType !== 'text/html') {
if ($contentType === 'text/html') {
Expand Down Expand Up @@ -277,6 +295,9 @@ public function setRecipients(): void {
$this->symfonyEmail->bcc(...$this->convertAddresses($this->getBcc()));
}

/**
* @return $this
*/
public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
$this->setSubject($emailTemplate->renderSubject());
$this->setPlainBody($emailTemplate->renderText());
Expand Down

0 comments on commit a449bd1

Please sign in to comment.