render-context.php ➔ renderContextCompose()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Extension\RenderContext;
4
5
use Closure;
6
use League\Plates;
7
8
function renderContextCompose(callable $render_context_factory, $var_name) {
9
    return function(Plates\Template $template) use ($render_context_factory, $var_name) {
10 24
        $render_context = $render_context_factory($template->reference);
11 24
        return $template->withAddedData([
12 24
            $var_name => $render_context,
13 24
        ])->with('render_context', $render_context);
14 24
    };
15
}
16
17
function renderContextBind() {
18
    return function(Closure $inc, Template $template) use ($var_name) {
0 ignored issues
show
Bug introduced by RJ Garcia
The variable $var_name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
19
        return $template->get('render_context')
20
            ? $inc->bindTo($template->get('render_context'))
21
            : $inc;
22
    };
23
}
24