1 | <?php |
||
34 | class MailService implements MailServiceInterface, EventsCapableInterface, MailListenerAwareInterface |
||
35 | { |
||
36 | /** |
||
37 | * @var TransportInterface |
||
38 | */ |
||
39 | private $transport; |
||
40 | /** |
||
41 | * @var TemplateRendererInterface |
||
42 | */ |
||
43 | private $renderer; |
||
44 | /** |
||
45 | * @var EventManagerInterface |
||
46 | */ |
||
47 | private $events; |
||
48 | /** |
||
49 | * @var EmailBuilderInterface |
||
50 | */ |
||
51 | private $emailBuilder; |
||
52 | /** |
||
53 | * @var AttachmentParserManagerInterface |
||
54 | */ |
||
55 | private $attachmentParserManager; |
||
56 | |||
57 | /** |
||
58 | * Creates a new MailService |
||
59 | * @param TransportInterface $transport |
||
60 | * @param TemplateRendererInterface $renderer |
||
61 | 33 | * @param EmailBuilderInterface $emailBuilder |
|
62 | * @param AttachmentParserManagerInterface $attachmentParserManager |
||
63 | 33 | * @param EventManagerInterface|null $events |
|
64 | 33 | */ |
|
65 | 33 | public function __construct( |
|
78 | |||
79 | private function initEventManager(EventManagerInterface $events = null): EventManagerInterface |
||
88 | |||
89 | 9 | /** |
|
90 | * Tries to send the message, returning a MailResult object |
||
91 | * @param string|array|Email $email |
||
92 | 9 | * @param array $options |
|
93 | * @return ResultInterface |
||
94 | * @throws NotFoundExceptionInterface |
||
95 | 9 | * @throws ContainerExceptionInterface |
|
96 | * @throws Exception\InvalidArgumentException |
||
97 | * @throws Exception\EmailNotFoundException |
||
98 | 5 | * @throws Exception\MailException |
|
99 | 9 | */ |
|
100 | 4 | public function send($email, array $options = []): ResultInterface |
|
140 | |||
141 | /** |
||
142 | * Creates a new MailEvent object |
||
143 | * @param Email $email |
||
144 | * @param string $name |
||
145 | * @param ResultInterface $result |
||
146 | 21 | * @return MailEvent |
|
147 | */ |
||
148 | 21 | private function createMailEvent( |
|
160 | |||
161 | 2 | private function createMessageFromEmail(Email $email): Message |
|
170 | 1 | ||
171 | 1 | /** |
|
172 | 1 | * Sets the message body |
|
173 | * @param string|Mime\Part|Mime\Message $body |
||
174 | * @param string $charset |
||
175 | * @return Mime\Message |
||
176 | * @throws Mime\Exception\InvalidArgumentException |
||
177 | 20 | */ |
|
178 | 20 | private function buildBody($body, string $charset): Mime\Message |
|
194 | 3 | ||
195 | 3 | /** |
|
196 | 3 | * Attaches files to the message if any |
|
197 | * @param Message $message |
||
198 | * @param Email $email |
||
199 | * @throws Exception\InvalidAttachmentException |
||
200 | 5 | * @throws NotFoundExceptionInterface |
|
201 | 2 | * @throws ContainerExceptionInterface |
|
202 | 2 | * @throws InvalidArgumentException |
|
203 | 2 | */ |
|
204 | 2 | private function attachFiles(Message $message, Email $email) |
|
238 | 3 | ||
239 | /** |
||
240 | 3 | * Retrieve the event manager |
|
241 | 3 | * Lazy-loads an EventManager instance if none registered. |
|
242 | * @return EventManagerInterface |
||
243 | 3 | */ |
|
244 | public function getEventManager(): EventManagerInterface |
||
248 | |||
249 | 3 | /** |
|
250 | 3 | * Attaches a new MailListenerInterface |
|
251 | 3 | * @param MailListenerInterface $mailListener |
|
252 | * @param int $priority |
||
253 | * @return void |
||
254 | */ |
||
255 | public function attachMailListener(MailListenerInterface $mailListener, $priority = 1) |
||
259 | 7 | ||
260 | /** |
||
261 | * Detaches provided MailListener |
||
262 | * @param MailListenerInterface $mailListener |
||
263 | 2 | * @return void |
|
264 | 2 | */ |
|
265 | 1 | public function detachMailListener(MailListenerInterface $mailListener) |
|
269 | } |
||
270 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.