GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Twig::getTwig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * View
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\View;
10
11
use Pimf\Contracts\Reunitable;
12
use Pimf\View;
13
use Pimf\Config;
14
15
16
/**
17
 * A view for TWIG a flexible, fast, and secure template engine for PHP.
18
 *
19
 * For use please add the following code to the end of the config.app.php file:
20
 *
21
 * <code>
22
 *
23
 * 'view' => array(
24
 *
25
 *   'twig' => array(
26
 *     'cache'       => true,  // if compilation caching should be used
27
 *     'debug'       => false, // if set to true, you can display the generated nodes
28
 *     'auto_reload' => true,  // useful to recompile the template whenever the source code changes
29
 *  ),
30
 *
31
 * ),
32
 *
33
 * </code>
34
 *
35
 * @link    http://twig.sensiolabs.org/documentation
36
 * @package View
37
 * @author  Gjero Krsteski <[email protected]>
38
 * @codeCoverageIgnore
39
 */
40
class Twig extends View implements Reunitable
41
{
42
    /**
43
     * @var \Twig_Environment
44
     */
45
    protected $twig;
46
47
    /**
48
     * @param string $template
49
     * @param array  $data
50
     */
51
    public function __construct($template, array $data = array())
52
    {
53
        parent::__construct($template, $data);
54
55
        $conf = Config::get('view.twig');
56
57
        require_once BASE_PATH . "Twig/vendor/autoload.php";
58
59
        $options = array(
60
            'debug'       => $conf['debug'],
61
            'auto_reload' => $conf['auto_reload']
62
        );
63
64
        if ($conf['cache'] === true) {
65
            $options['cache'] = $this->path . '/twig_cache';
66
        }
67
68
        // define the Twig environment.
69
        $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array($this->path)), $options);
70
    }
71
72
    /**
73
     * @return \Twig_Environment
74
     */
75
    public function getTwig()
76
    {
77
        return $this->twig;
78
    }
79
80
    /**
81
     * Puts the template an the variables together.
82
     *
83
     * @return string|void
84
     */
85
    public function reunite()
86
    {
87
        return $this->twig->render(
88
            $this->template, $this->data->getArrayCopy()
89
        );
90
    }
91
}
92