Completed
Push — master ( 2377d3...b3978b )
by
unknown
42:22 queued 28:51
created

PhpRenderTemplate   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A renderTemplate() 0 8 2
A createInclude() 0 6 1
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 16
    public function __construct(callable $bind = null) {
12 16
        $this->bind = $bind;
13 16
    }
14
15 16
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $render = null) {
16 16
        $inc = self::createInclude();
17 16
        $inc = $this->bind ? ($this->bind)($inc, $template) : $inc;
18
19 16
        return Plates\Util\obWrap(function() use ($inc, $template) {
20
            $inc($template->get('path'), $template->data);
21 16
        });
22
    }
23
24
    private static function createInclude() {
25
        return function() {
26
            extract(func_get_arg(1));
0 ignored issues
show
Bug introduced by
func_get_arg(1) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
27
            include func_get_arg(0);
28
        };
29
    }
30
}
31