LatteServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 3 1
A register() 0 18 2
1
<?php
2
namespace Wandu\View\Bridges\Latte;
3
4
use Latte\Engine;
5
use Latte\Loaders\FileLoader;
6
use Wandu\Config\Contracts\Config;
7
use Wandu\DI\ContainerInterface;
8
use Wandu\DI\ServiceProviderInterface;
9
use Wandu\View\Contracts\RenderInterface;
10
11
class LatteServiceProvider implements ServiceProviderInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function register(ContainerInterface $app)
17
    {
18
        $app->closure(Engine::class, function (Config $config) {
19
            $engine = new Engine();
20
            $engine->setLoader(new FileLoader());
21
            $cachePath = $config->get('view.cache');
22
            if ($cachePath) {
23
                $engine->setTempDirectory($cachePath);
24
            }
25
            return $engine;
26
        });
27
        $app->closure(RenderInterface::class, function (Engine $engine, Config $config) {
28
            return new LatteView(
29
                $engine,
30
                $config->get('view.path')
31
            );
32
        });
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function boot(ContainerInterface $app)
39
    {
40
    }
41
}
42