Completed
Push — master ( eaa10a...12d04d )
by Albert
03:25
created

TwigServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 5
dl 0
loc 33
ccs 0
cts 16
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 1
1
<?php
2
3
namespace Albert221\Blog\ServiceProvider;
4
5
use Albert221\Blog\Pagination\PaginatorBuilder;
6
use League\Container\ServiceProvider\AbstractServiceProvider;
7
use Twig_Environment;
8
use Twig_Loader_Filesystem;
9
10
class TwigServiceProvider extends AbstractServiceProvider
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected $provides = [
16
        'twig',
17
        'paginatorBuilder'
18
    ];
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function register()
24
    {
25
        $this->getContainer()->share('twig', function () {
26
            $loader = new Twig_Loader_Filesystem(
27
                $this->getContainer()->get('baseDir').'/views'
28
            );
29
            
30
            return new Twig_Environment($loader, [
31
                'autoescape' => false
32
            ]);
33
        });
34
        
35
        $this->getContainer()->share('paginatorBuilder', function () {
36
            return new PaginatorBuilder(
37
                $this->getContainer()->get('twig'),
38
                $this->getContainer()->get('config')['pagination']['perPage']
39
            );
40
        });
41
    }
42
}
43