Test Failed
Push — master ( 62e8aa...e74fb5 )
by Julien
04:23
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 13
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 17 1
1
<?php
2
/**
3
 * This file is part of the Zemit Framework.
4
 *
5
 * (c) Zemit Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.txt
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zemit\Provider\Imap;
12
13
use Phalcon\Di\DiInterface;
14
use Zemit\Config\ConfigInterface;
15
use Zemit\Provider\AbstractServiceProvider;
16
17
class ServiceProvider extends AbstractServiceProvider
18
{
19
    protected string $serviceName = 'imap';
20
    
21
    public function register(DiInterface $di): void
22
    {
23
        $di->setShared($this->getName(), function (?array $options = null) use ($di) {
24
    
25
            $config = $di->get('config');
26
            assert($config instanceof ConfigInterface);
27
    
28
            $options ??= $config->pathToArray('imap', []);
29
30
            return new \PhpImap\Mailbox(
31
                $options['path'] ?? '',
32
                $options['login'] ?? '',
33
                $options['password'] ?? '',
34
                $options['attachmentsDir'] ?? '',
35
                $options['serverEncoding'] ?? 'UTF-8',
36
                $options['trimImapPath'] ?? true,
37
                $options['attachmentFilenameMode'] ?? false,
38
            );
39
        });
40
    }
41
}
42