Conditions | 3 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
22 | 1 | public function addToContainer(Container $c) |
|
23 | { |
||
24 | 1 | $c[MailService::class] = $c->factory(function (Container $c) { |
|
25 | 1 | $view = $c->get(ViewEngine::class); |
|
26 | 1 | $siteConfig = $c->get(SiteConfig::class); |
|
27 | 1 | $mailService = new MailService(); |
|
28 | 1 | $transport = new Sendmail(); |
|
29 | |||
30 | 1 | if ($c->has('mail')) { |
|
31 | 1 | $settings = $c->get('mail'); |
|
32 | |||
33 | 1 | if (isset($settings['name'], $settings['host'], $settings['port'])) { |
|
34 | 1 | $options = new SmtpOptions($settings); |
|
35 | 1 | $transport = new Smtp($options); |
|
36 | } |
||
37 | } |
||
38 | |||
39 | 1 | $mailService->setView($view); |
|
40 | 1 | $mailService->setSiteConfig($siteConfig); |
|
41 | 1 | $mailService->setTransport($transport); |
|
42 | |||
43 | 1 | return $mailService; |
|
44 | 1 | }); |
|
47 |