Completed
Push — 179-travis-with-peridot ( f13604...56a498 )
by
unknown
12:25 queued 29s
created

name.php ➔ extResolveName()   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 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template;
4
5
use League\Plates;
6
7
/** appends a suffix to the name */
8
function extResolveName($ext = 'phtml') {
9
    return function($name, array $context) use ($ext) {
10
        return [$name . '.' . $ext, $context];
11
    };
12
}
13
14
function prefixResolveName($prefix) {
15
    return function($name, array $context) use ($prefix) {
16
        return [
17
            Plates\Util\joinPath([$prefix, $name]),
18
            $context
19
        ];
20
    };
21
}
22
23
/** If the template context stores a current directory and  */
24
function relativeResolveName() {
25
    return function($name, array $context) {
26
        if (strpos($path, './') !== 0 || !isset($context['current_directory'])) {
0 ignored issues
show
Bug introduced by
The variable $path 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...
27
            return $name; // nothing to do
28
        }
29
30
        return [
31
            Plates\Util\joinPath([$context['current_directory'], substr($path, 2)]),
32
            $context
33
        ];
34
    };
35
}
36
37
/** assumes the template name is in the format of `folder::path`.
38
    folders */
39
function folderResolveName(array $folders, $sep = '::') {
40
    return function($name, array $context) use ($folders, $sep) {
41
        if (strpos($name, $sep) === false) {
42
            return [$name, $context];
43
        }
44
45
        list($folder, $path) = explode($sep, $name);
46
        if (!isset($folders[$folder])) {
47
            return [$name, $context];
48
        }
49
50
        return [
51
            Plates\Util\joinPath([$folders[$folder], $path]),
52
            $context
53
        ];
54
    };
55
}
56
57
/** will automatically*/
58
function defaultFolderResolveName(array $folders, $sep = '::') {
59
    return function($name, array $context) use ($folders, $sep) {
0 ignored issues
show
Unused Code introduced by
The parameter $name 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 $context 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...
60
        // if (strpos($name, $sep))
61
    };
62
}
63