Skip to content

Commit 1d418fa

Browse files
committed
add array transport
1 parent aa07573 commit 1d418fa

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Illuminate\Mail\Transport;
4+
5+
use Illuminate\Support\Collection;
6+
use Symfony\Component\Mailer\Envelope;
7+
use Symfony\Component\Mailer\SentMessage;
8+
use Symfony\Component\Mailer\Transport\TransportInterface;
9+
use Symfony\Component\Mime\RawMessage;
10+
11+
class ArrayTransport implements TransportInterface
12+
{
13+
/**
14+
* The collection of Symfony Messages.
15+
*
16+
* @var \Illuminate\Support\Collection
17+
*/
18+
protected Collection $messages;
19+
20+
/**
21+
* Create a new array transport instance.
22+
*
23+
* @return void
24+
*/
25+
public function __construct()
26+
{
27+
$this->messages = new Collection();
28+
}
29+
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
34+
{
35+
return $this->messages[] = new SentMessage($message, $envelope ?? Envelope::create($message));
36+
}
37+
38+
/**
39+
* Retrieve the collection of messages.
40+
*
41+
* @return \Illuminate\Support\Collection
42+
*/
43+
public function messages(): Collection
44+
{
45+
return $this->messages;
46+
}
47+
48+
/**
49+
* Clear all of the messages from the local collection.
50+
*
51+
* @return \Illuminate\Support\Collection
52+
*/
53+
public function flush(): Collection
54+
{
55+
return $this->messages = new Collection();
56+
}
57+
58+
/**
59+
* Get the string representation of the transport.
60+
*
61+
* @return string
62+
*/
63+
public function __toString(): string
64+
{
65+
return 'array';
66+
}
67+
}

0 commit comments

Comments
 (0)