MailPackage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A addToContainer() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\Mail;
6
7
use Barnacle\Container;
8
use Barnacle\RegistrationInterface;
9
use Bone\View\ViewEngine;
10
use Bone\Server\Environment;
11
use Bone\Server\SiteConfig;
12
use Bone\Mail\Service\MailService;
13
use Laminas\Mail\Transport\Sendmail;
0 ignored issues
show
Bug introduced by
The type Laminas\Mail\Transport\Sendmail was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Laminas\Mail\Transport\Smtp;
0 ignored issues
show
Bug introduced by
The type Laminas\Mail\Transport\Smtp was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Laminas\Mail\Transport\SmtpOptions;
0 ignored issues
show
Bug introduced by
The type Laminas\Mail\Transport\SmtpOptions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Symfony\Component\Mailer\Mailer;
17
use Symfony\Component\Mailer\Transport;
18
use function getenv;
19
20
class MailPackage implements RegistrationInterface
21
{
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
            $dsn = getenv('MAILER_DSN') ?: 'sendmail://default';
28 1
            $mailService = new MailService();
29
            $transport = Transport::fromDsn($dsn);
30 1
            $mailer = new Mailer($transport);
0 ignored issues
show
Unused Code introduced by
The assignment to $mailer is dead and can be removed.
Loading history...
31 1
            $mailService->setView($view);
32
            $mailService->setSiteConfig($siteConfig);
33 1
            $mailer  = new Mailer($transport);
34 1
            $mailService->setMailer($mailer);
35 1
36
            return $mailService;
37
        });
38
    }
39
}
40