Test Failed
Push — master ( 07210e...c1dbb6 )
by Julien
04:25
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 1

1 Method

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