Skip to content

Commit 1f905fd

Browse files
authored
Merge pull request #116 from phenixphp/feature/improve-mailable-api
refactor: change self by static for better class resolution
2 parents a697243 + 20a5366 commit 1f905fd

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/Mail/Contracts/Mailable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
interface Mailable
1111
{
12-
public function from(Address|array|string $from): self;
12+
public function from(Address|array|string $from): static;
1313

14-
public function to(array|string $to): self;
14+
public function to(array|string $to): static;
1515

16-
public function cc(array|string $cc): self;
16+
public function cc(array|string $cc): static;
1717

18-
public function bcc(array|string $bcc): self;
18+
public function bcc(array|string $bcc): static;
1919

2020
public function build(): self;
2121

src/Mail/Mailable.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,49 +48,49 @@ abstract class Mailable implements MailableContract
4848

4949
abstract public function build(): self;
5050

51-
public function to(array|string $to): self
51+
public function to(array|string $to): static
5252
{
5353
$this->to = array_merge($this->to, (array) $to);
5454

5555
return $this;
5656
}
5757

58-
public function cc(array|string $cc): self
58+
public function cc(array|string $cc): static
5959
{
6060
$this->cc = (array) $cc;
6161

6262
return $this;
6363
}
6464

65-
public function bcc(array|string $bcc): self
65+
public function bcc(array|string $bcc): static
6666
{
6767
$this->bcc = (array) $bcc;
6868

6969
return $this;
7070
}
7171

72-
public function tagHeader(string $value): self
72+
public function tagHeader(string $value): static
7373
{
7474
$this->headers[] = new TagHeader($value);
7575

7676
return $this;
7777
}
7878

79-
public function metadataHeader(string $key, string $value): self
79+
public function metadataHeader(string $key, string $value): static
8080
{
8181
$this->headers[] = new MetadataHeader($key, $value);
8282

8383
return $this;
8484
}
8585

86-
public function textHeader(string $name, string $value): self
86+
public function textHeader(string $name, string $value): static
8787
{
8888
$this->headers[] = new UnstructuredHeader($name, $value);
8989

9090
return $this;
9191
}
9292

93-
public function idHeader(string $name, array|string $value): self
93+
public function idHeader(string $name, array|string $value): static
9494
{
9595
$this->headers[] = new IdentificationHeader($name, $value);
9696

@@ -130,36 +130,36 @@ public function toMail(): Email
130130
return $email;
131131
}
132132

133-
public function from(Address|array|string $from): self
133+
public function from(Address|array|string $from): static
134134
{
135135
$this->from = $from instanceof Address ? [$from] : (array) $from;
136136

137137
return $this;
138138
}
139139

140-
protected function replyTo(array|string $replyTo): self
140+
protected function replyTo(array|string $replyTo): static
141141
{
142142
$this->replyTo = (array) $replyTo;
143143

144144
return $this;
145145
}
146146

147-
protected function subject(string $subject): self
147+
protected function subject(string $subject): static
148148
{
149149
$this->subject = $subject;
150150

151151
return $this;
152152
}
153153

154-
protected function view(string $view, array $viewData = []): self
154+
protected function view(string $view, array $viewData = []): static
155155
{
156156
$this->view = $view;
157157
$this->viewData = $viewData;
158158

159159
return $this;
160160
}
161161

162-
protected function attachment(string $path, string|null $name = null, string|null $mime = null): self
162+
protected function attachment(string $path, string|null $name = null, string|null $mime = null): static
163163
{
164164
if (File::exists($path) === false) {
165165
throw new InvalidArgumentException("File {$path} does not exist.");
@@ -174,7 +174,7 @@ protected function attachment(string $path, string|null $name = null, string|nul
174174
return $this;
175175
}
176176

177-
protected function attachments(array $attachments): self
177+
protected function attachments(array $attachments): static
178178
{
179179
foreach ($attachments as $attachment) {
180180
if (is_string($attachment)) {

0 commit comments

Comments
 (0)