EmailBuilderFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailer\Model;
5
6
use AcMailer\Exception\ServiceNotCreatedException;
7
use Psr\Container\ContainerExceptionInterface;
8
use Psr\Container\ContainerInterface;
9
use Psr\Container\NotFoundExceptionInterface;
10
11
class EmailBuilderFactory
12
{
13
    /**
14
     * @param ContainerInterface $container
15
     * @return EmailBuilder
16
     * @throws ServiceNotCreatedException
17
     * @throws ContainerExceptionInterface
18
     * @throws NotFoundExceptionInterface
19
     */
20
    public function __invoke(ContainerInterface $container)
21
    {
22
        if (! $container->has('config')) {
23
            throw new ServiceNotCreatedException('Cannot find a config array in the container');
24
        }
25
        $config = $container->get('config');
26
27
        return new EmailBuilder($config['acmailer_options']['emails'] ?? []);
28
    }
29
}
30