1 | <?php namespace nyx\notify\transports\mail\drivers; |
||
24 | class Mailgun implements mail\interfaces\Driver |
||
25 | { |
||
26 | /** |
||
27 | * The traits of a Mailgun Mail Driver instance. |
||
28 | */ |
||
29 | use traits\ExposesBcc; |
||
30 | |||
31 | /** |
||
32 | * @var string The API key used to authorize requests to Mailgun's API. |
||
33 | */ |
||
34 | protected $key; |
||
35 | |||
36 | /** |
||
37 | * @var string The API endpoint used by the Driver. |
||
38 | */ |
||
39 | protected $endpoint; |
||
40 | |||
41 | /** |
||
42 | * @var \GuzzleHttp\ClientInterface The underlying HTTP Client instance. |
||
43 | */ |
||
44 | protected $client; |
||
45 | |||
46 | /** |
||
47 | * Creates a new Mailgun Mail Driver instance. |
||
48 | * |
||
49 | * @param \GuzzleHttp\ClientInterface $client The HTTP Client to use. |
||
50 | * @param string $key The API key to be used to authorize requests to Mailgun's API. |
||
51 | * @param string $domain The domain to use to send mails from (must be registered with Mailgun). |
||
52 | */ |
||
53 | public function __construct(\GuzzleHttp\ClientInterface $client, string $key, string $domain) |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function send(\Swift_Mime_Message $message, &$failures = null) |
||
87 | |||
88 | /** |
||
89 | * Returns an array of all of the recipients of the message (to, cc and bcc) in a format understood by |
||
90 | * Mailgun's "messages.mime" endpoint for the "to" field. |
||
91 | * |
||
92 | * @param \Swift_Mime_Message $message |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function getRecipients(\Swift_Mime_Message $message) : array |
||
106 | } |
||
107 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: