@@ -25,8 +25,7 @@ public function __construct(
2525 private(set) null |string |array |ArrayInterface |Address $ cc = null ,
2626 private(set) null |string |array |ArrayInterface |Address $ bcc = null ,
2727 private(set) ?string $ subject = null ,
28- private(set) null |string |View $ html = null ,
29- private(set) ?string $ text = null ,
28+ private(set) ?string $ content = null ,
3029 private(set) array $ attachments = [],
3130 private(set) EmailPriority |int $ priority = EmailPriority::NORMAL ,
3231 private(set) array $ headers = [],
@@ -93,21 +92,11 @@ public function subject(string|Stringable $subject): self
9392 }
9493
9594 /**
96- * Defines the HTML body of the email.
95+ * Defines the content of the email.
9796 */
98- public function html (string |View $ html ): self
97+ public function content (string |View $ content ): self
9998 {
100- $ this ->html = $ html ;
101-
102- return $ this ;
103- }
104-
105- /**
106- * Defines the text body of the email.
107- */
108- public function text (string $ text ): self
109- {
110- $ this ->text = $ text ;
99+ $ this ->content = $ content ;
111100
112101 return $ this ;
113102 }
@@ -137,13 +126,7 @@ public function headers(array $headers): self
137126 */
138127 public function attach (Attachment ...$ attachments ): self
139128 {
140- foreach ($ attachments as $ attachment ) {
141- if (! ($ attachment instanceof Attachment)) {
142- throw new \InvalidArgumentException (sprintf ('All attachments must be instances of `%s`. ' , Attachment::class));
143- }
144-
145- $ this ->attachments [] = $ attachment ;
146- }
129+ $ this ->attachments = [...$ this ->attachments , ...$ attachments ];
147130
148131 return $ this ;
149132 }
@@ -176,16 +159,15 @@ public function make(): Email
176159 return new GenericEmail (
177160 subject: $ this ->subject ,
178161 to: Arr \wrap ($ this ->to ),
162+ content: $ this ->content ,
179163 from: Arr \wrap ($ this ->from ),
180164 cc: Arr \wrap ($ this ->cc ),
181165 bcc: Arr \wrap ($ this ->bcc ),
182166 replyTo: Arr \wrap ($ this ->replyTo ),
167+ headers: $ this ->headers ,
183168 priority: is_int ($ this ->priority )
184169 ? EmailPriority::from ($ this ->priority )
185170 : $ this ->priority ,
186- headers: $ this ->headers ,
187- html: $ this ->html ,
188- text: $ this ->text ,
189171 attachments: $ this ->attachments ,
190172 );
191173 }
0 commit comments