SenderBootstrapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBindings() 0 13 1
A getBindings() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Bootstrappers\Email;
6
7
use AbterPhp\Framework\Email\MessageFactory;
8
use AbterPhp\Framework\Email\Sender;
9
use Opulence\Ioc\Bootstrappers\Bootstrapper;
10
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
11
use Opulence\Ioc\IContainer;
12
use Symfony\Component\Mailer\Mailer;
13
use Symfony\Component\Mailer\Transport\TransportInterface;
14
15
class SenderBootstrapper extends Bootstrapper implements ILazyBootstrapper
16
{
17
    /**
18
     * @inheritdoc
19
     */
20
    public function getBindings(): array
21
    {
22
        return [
23
            Sender::class,
24
        ];
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function registerBindings(IContainer $container): void
31
    {
32
        /** @var TransportInterface $transport */
33
        $transport = $container->resolve(TransportInterface::class);
34
35
        /** @var MessageFactory $messageFactory */
36
        $messageFactory = $container->resolve(MessageFactory::class);
37
38
        $mailer = new Mailer($transport, null, null);
39
40
        $sender = new Sender($mailer, $messageFactory);
41
42
        $container->bindInstance(Sender::class, $sender);
43
    }
44
}
45