1 | <?php |
||
14 | class SMTPMailService implements MailService |
||
15 | { |
||
16 | /** |
||
17 | * @var SMTPAuthenticator |
||
18 | */ |
||
19 | protected $authenticator; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $client_domain; |
||
25 | |||
26 | /** |
||
27 | * @var SMTPConnector |
||
28 | */ |
||
29 | private $connector; |
||
30 | |||
31 | /** |
||
32 | * @var SMTPClient|null |
||
33 | */ |
||
34 | private $client; |
||
35 | |||
36 | /** |
||
37 | * @param SMTPConnector $connector provides the SMTP connection |
||
38 | * @param SMTPAuthenticator $authenticator performs SMTP authentication |
||
39 | * @param string $client_domain client domain-name (provided in handshakes when connecting) |
||
40 | */ |
||
41 | 1 | public function __construct(SMTPConnector $connector, SMTPAuthenticator $authenticator, $client_domain) |
|
47 | |||
48 | 1 | public function send(Message $message) |
|
60 | |||
61 | /** |
||
62 | * Internally disconnect the SMTP Client. |
||
63 | * |
||
64 | * Long-running services may wish to disconnect the SMTP client after sending a batch |
||
65 | * of Messages, to avoid timeouts. |
||
66 | * |
||
67 | * @return void |
||
68 | */ |
||
69 | public function disconnect() |
||
76 | |||
77 | /** |
||
78 | * Connect and authenticate SMTP Client (if not already connected) |
||
79 | * |
||
80 | * @return SMTPClient |
||
81 | */ |
||
82 | 1 | protected function getClient() |
|
92 | |||
93 | /** |
||
94 | * Determine the sender e-mail address from the "Sender" or first "From" field of the Message |
||
95 | * |
||
96 | * @param Message $message |
||
97 | * |
||
98 | * @return string sender e-mail address |
||
99 | */ |
||
100 | 1 | private function getSender(Message $message) |
|
112 | |||
113 | /** |
||
114 | * Extract recipient e-mail addresses from the "To", "CC" and "BCC" fields of the Message |
||
115 | * |
||
116 | * @param Message $message |
||
117 | * |
||
118 | * @return string[] list of recipient e-mail addresses |
||
119 | */ |
||
120 | 1 | private function getRecipients(Message $message) |
|
138 | } |
||
139 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.