Passed
Pull Request — master (#2)
by Chauncey
02:01
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;
7
8
// From 'charcoal-view'
9
use Charcoal\View\AbstractLoader;
10
use Charcoal\View\LoaderInterface;
11
12
/**
13
 * - The mustache template loader finds a mustache template file in directories.
14
 */
15 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...
16
    Mustache_Loader,
17
    LoaderInterface
18
{
19
    /**
20
     * Determine if the variable is a template literal.
21
     *
22
     * This method looks for any tag delimiters in the given string,
23
     * which a file path would most likely not have.
24
     *
25
     * @todo   Add support for custom delimiters.
26
     * @param  string $ident The template being evaluated.
27
     * @return boolean
28
     */
29
    protected function isTemplateString($ident)
30
    {
31
        return strpos($ident, '{{') !== false || parent::isTemplateString($ident);
32
    }
33
34
    /**
35
     * Convert an identifier to a file path.
36
     *
37
     * @param string $ident The template identifier to convert to a filename.
38
     * @return string
39
     */
40
    protected function filenameFromIdent($ident)
41
    {
42
        $filename  = str_replace([ '\\' ], '.', $ident);
43
        $filename .= '.mustache';
44
45
        return $filename;
46
    }
47
}
48