Completed
Push — v4.0-dev ( 6660e2...b14a8f )
by
unknown
11s
created

FoldersExtension::folderResolveName()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 1
nop 0
dl 0
loc 14
ccs 0
cts 11
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Extension;
4
5
use League\Plates;
6
7
class FoldersExtension implements Plates\Extension
8
{
9
    public function register(Plates\Engine $engine) {
10
11
    }
12
13
    /** assumes the template name is in the format of `folder::path`.
14
        folders */
15
    private function folderResolveName() {
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
16
        return function($name, array $context) use ($folders, $sep) {
0 ignored issues
show
Bug introduced by
The variable $folders 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...
Bug introduced by
The variable $sep 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...
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...
17
            if (strpos($name, $sep) === false) {
18
                return $name;
19
            }
20
21
            list($folder, $path) = explode($sep, $name);
22
            if (!isset($folders[$folder])) {
23
                return $name;
24
            }
25
26
            return Plates\Util\joinPath([$folders[$folder], $path]);
27
        };
28
    }
29
30
    /** Creates the folder fallback resolve name */
31
    private function folderFallbackResolveName() {
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
32
        return function($name, array $context, $resolve) use ($folders, $sep) {
0 ignored issues
show
Bug introduced by
The variable $folders 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...
Bug introduced by
The variable $sep 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...
33
            if (file_exists($name)) {
34
                return $name;
35
            }
36
37
            $resolve($name);
38
        };
39
    }
40
}
41