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

PhpLoader::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\Php;
4
5
// From 'charcoal-view'
6
use Charcoal\View\AbstractLoader;
7
use Charcoal\View\LoaderInterface;
8
9
/**
10
 * PHP Template Loader
11
 *
12
 * Finds a PHP template file in a collection of directory paths.
13
 */
14 View Code Duplication
class PhpLoader extends AbstractLoader implements LoaderInterface
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...
15
{
16
    /**
17
     * Determine if the variable is a template literal.
18
     *
19
     * This method looks for any PHP tags in the given string,
20
     * which a file path would most likely not have.
21
     *
22
     * @todo   Add support for custom delimiters.
23
     * @param  string $ident The template being evaluated.
24
     * @return boolean
25
     */
26
    protected function isTemplateString($ident)
27
    {
28
        return strpos($ident, '<?') !== false || parent::isTemplateString($ident);
29
    }
30
31
    /**
32
     * Convert an identifier to a file path.
33
     *
34
     * @param string $ident The identifier to convert.
35
     * @return string
36
     */
37
    protected function filenameFromIdent($ident)
38
    {
39
        $filename = str_replace([ '\\' ], '.', $ident);
40
        $filename .= '.php';
41
42
        return $filename;
43
    }
44
}
45