MailTransport::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Da\Mailer\Transport;
4
5
use Swift_MailTransport;
0 ignored issues
show
Bug introduced by
The type Swift_MailTransport 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...
6
use Symfony\Component\Mailer\Transport\Dsn;
7
use Symfony\Component\Mailer\Transport\NativeTransportFactory;
8
9
class MailTransport implements TransportInterface
10
{
11
    /**
12
     * @var \Symfony\Component\Mailer\Transport\TransportInterface
13
     */
14
    private $instance;
15
    private string $dsn;
16
    public function __construct(string $dsn)
17
    {
18
        $this->dsn = $dsn;
19
    }
20
21
    /**
22
     * @return \Symfony\Component\Mailer\Transport\TransportInterface
23 4
     */
24
    public function getInstance(): \Symfony\Component\Mailer\Transport\TransportInterface
25 4
    {
26 4
        if ($this->instance === null) {
27
            $dsn = Dsn::fromString($this->dsn);
28
            $this->instance = (new NativeTransportFactory())->create($dsn);
29
        }
30
31
        return $this->instance;
32
    }
33
}
34