Completed
Push — 186-data ( 572d68...d14d7f )
by
unknown
10:34
created

resolve-data.php ➔ idResolveData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Extension\Data;
4
5
use League\Plates\HydrateTemplate\CallableHydrateTemplate;
6
7
function idResolveData() {
8
    return function(ResolveDataArgs $args) {
9
        return $args->data;
10
    };
11
}
12
13
function globalResolveData() {
14
    return function(ResolveDataArgs $args, $next) {
15
        $ctx = $args->getContext();
16
        if (!isset($ctx['globals'])) {
17
            return $next($args);
18
        }
19
20
        return $next($args->withAddedData($ctx['globals']));
21
    };
22
}
23
24
function perTemplateResolveData() {
25
    return function(ResolveDataArgs $args, $next) {
26
        $ctx = $args->getContext();
27
        $name = $args->getTemplate()->name;
28
        if (!isset($ctx['pre_assigned_template_data'][$name])) {
29
            return $next($args);
30
        }
31
32
        return $next($args->withAddedData($ctx['pre_assigned_template_data'][$name]));
33
    };
34
}
35
36
/** Allow view composers which will dynamically assign data to a given template */
37
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...
38
    return function() {
39
40
    };
41
}
42
43
function folderResolveData($sep) {
44
    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...
45
        // return $args->
46
    };
47
}
48