PhpRenderTemplate::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\RenderTemplate;
4
5
use League\Plates;
6
7
final class PhpRenderTemplate implements Plates\RenderTemplate
8
{
9
    private $bind;
10
11 24
    public function __construct(callable $bind = null) {
12 24
        $this->bind = $bind;
13 24
    }
14
15 24
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $render = null) {
16 24
        $inc = self::createInclude();
17 24
        $inc = $this->bind ? ($this->bind)($inc, $template) : $inc;
18
19 24
        return Plates\Util\obWrap(function() use ($inc, $template) {
20 24
            $inc($template->get('path'), $template->data);
21 24
        });
22
    }
23
24
    private static function createInclude() {
25 24
        return function() {
26 24
            extract(func_get_arg(1));
0 ignored issues
show
Bug introduced by RJ Garcia
func_get_arg(1) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
27 24
            include func_get_arg(0);
28 24
        };
29
    }
30
}
31