Completed
Push — develop ( 9a63dd...a5c294 )
by
unknown
09:36
created

MailServiceFactory::createService()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 24
rs 8.9713
cc 2
eloc 12
nc 2
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** MailServiceFactory.php */
11
namespace Core\Mail;
12
13
use Zend\ServiceManager\FactoryInterface;
14
use Zend\ServiceManager\ServiceLocatorInterface;
15
16
class MailServiceFactory implements FactoryInterface
17
{
18
     
19
    /* (non-PHPdoc)
20
     * @see \Zend\ServiceManager\FactoryInterface::createService()
21
     */
22
    public function createService(ServiceLocatorInterface $serviceLocator)
23
    {
24
25
        $config = $serviceLocator->get('Config');
26
        $mails = isset($config['mails']) ? $config['mails'] : [];
27
28
        /* @var \Auth\Options\ModuleOptions $authOptions */
29
        $authOptions = $serviceLocator->get('Auth\Options');
30
        $configArray=[
31
                'from' => [
32
                    'name' => $authOptions->getFromName(),
33
                    'email' => $authOptions->getFromEmail()
34
                ],
35
        ];
36
37
        $configArray += $mails;
38
39
        $config      = new MailServiceConfig($configArray);
40
41
        $service   = new MailService($config);
42
43
        return $service;
44
45
    }
46
}
47