Test Failed
Push — master ( ffc597...4abc3b )
by Julien
12:58 queued 09:01
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 15.38%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
eloc 16
c 1
b 1
f 0
dl 0
loc 37
ccs 2
cts 13
cp 0.1538
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 24 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\View;
12
13
use Phalcon\Mvc\View;
14
use Phalcon\Mvc\View\Simple;
15
use InvalidArgumentException;
16
use Phalcon\Mvc\View\Engine\Php;
17
use Zemit\Listener\ViewListener;
0 ignored issues
show
Bug introduced by
The type Zemit\Listener\ViewListener was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Zemit\Mvc\View\Error as ViewError;
19
use Zemit\Provider\AbstractServiceProvider;
20
21
/**
22
 * Class ServiceProvider
23
 *
24
 * @author Julien Turbide <[email protected]>
25
 * @copyright Zemit Team <[email protected]>
26
 *
27
 * @since 1.0
28
 * @version 1.0
29
 *
30
 * @package Zemit\Provider\View
31
 */
32
class ServiceProvider extends AbstractServiceProvider
33
{
34
    /**
35
     * The Service name.
36
     * @var string
37
     */
38
    protected $serviceName = 'view';
39
    
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @return void
44
     */
45 4
    public function register(\Phalcon\Di\DiInterface $di): void
46
    {
47 4
        $di->setShared($this->getName(), function() use ($di) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
48
            $config = $di->get('config');
49
            $eventsManager = $di->get('eventsManager');
50
            
51
            $error = new ViewError();
52
            $error->setDI($di);
53
            $eventsManager->attach('view', $error);
54
            
55
            $view = new \Zemit\Mvc\View();
56
            $view->setMinify($config->app->minify);
57
            $view->registerEngines([
58
                '.phtml' => 'Phalcon\Mvc\View\Engine\Php',
59
                '.volt' => 'Phalcon\Mvc\View\Engine\Volt',
60
//                '.mhtml' => 'Phalcon\Mvc\View\Engine\Mustache',
61
//                '.twig' => 'Phalcon\Mvc\View\Engine\Twig', // @TODO fix for non-existing viewdir
62
//                '.tpl' => 'Phalcon\Mvc\View\Engine\Smarty'
63
            ]);
64
            
65
            $view->setEventsManager($eventsManager);
66
            $view->setDI($di);
67
            
68
            return $view;
69
        });
70
    }
71
}
72