Completed
Push — 186-data ( d4ee1e )
by
unknown
08:25 queued 10s
created

resolve-data.php ➔ perTemplateResolveData()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template;
4
5
function idResolveData() {
6
    return function(ResolveDataArgs $args) {
7
        return $args->data;
8
    };
9
}
10
11
function globalResolveData() {
12
    return function(ResolveDataArgs $args, $next) {
13
        $ctx = $args->getContext();
14
        if (!isset($ctx['globals'])) {
15
            return $next($args);
16
        }
17
18
        return $next($args->withAddedData($ctx['globals']));
19
    };
20
}
21
22
function perTemplateResolveData() {
23
    return function(ResolveDataArgs $args, $next) {
24
        $ctx = $args->getContext();
25
        $name = $args->getTemplate()->name;
26
        if (!isset($ctx['pre_assigned_template_data'][$name])) {
27
            return $next($args);
28
        }
29
30
        return $next($args->withAddedData($ctx['pre_assigned_template_data'][$name]));
31
    };
32
}
33
34
/** Allow view composers which will dynamically assign data to a given template */
35
function composerResolveData(array $composers) {
0 ignored issues
show
Unused Code introduced by
The parameter $composers is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    return function() {
37
38
    };
39
}
40
41
function folderResolveData($sep) {
42
    return function(ResolveDataArgs $args, $next) use ($sep) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $next is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
        // return $args->
44
    };
45
}
46