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

Complexity

Conditions 2
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 6
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
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