Passed
Push — master ( b912aa...9d745d )
by Mathieu
01:50
created

MustacheLoader::isTemplateString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Charcoal\View\Mustache;
4
5
// From Mustache
6
use Mustache_Loader as MustacheLoaderInterface;
7
8
// From 'charcoal-view'
9
use Charcoal\View\AbstractLoader;
10
use Charcoal\View\LoaderInterface;
11
12
/**
13
 * Mustache Template Loader
14
 *
15
 * Finds a Mustache template file in a collection of directory paths.
16
 */
17 View Code Duplication
class MustacheLoader extends AbstractLoader implements
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    LoaderInterface,
19
    MustacheLoaderInterface
20
{
21
    /**
22
     * Determine if the variable is a template literal.
23
     *
24
     * This method looks for any tag delimiters in the given string,
25
     * which a file path would most likely not have.
26
     *
27
     * @todo   Add support for custom delimiters.
28
     * @param  string $ident The template being evaluated.
29
     * @return boolean
30
     */
31
    protected function isTemplateString($ident)
32
    {
33
        return strpos($ident, '{{') !== false || parent::isTemplateString($ident);
34
    }
35
36
    /**
37
     * Convert an identifier to a file path.
38
     *
39
     * @param  string $ident The template identifier to convert to a filename.
40
     * @return string
41
     */
42
    protected function filenameFromIdent($ident)
43
    {
44
        $filename  = str_replace([ '\\' ], '.', $ident);
45
        $filename .= '.mustache';
46
47
        return $filename;
48
    }
49
}
50