LatteServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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