LocalViewFinder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findTemplate() 0 10 1
A listSearchPaths() 0 4 1
1
<?php
2
3
namespace mindplay\kisstpl;
4
5
use ReflectionClass;
6
7
/**
8
 * This view-finder assumes a local view-file located "locally", in the
9
 * same folder as the class-file, e.g.:
10
 *
11
 *     src/view/HomePage.php         # class file
12
 *     src/view/HomePage.view.php    # matching template (for default type "view")
13
 */
14
class LocalViewFinder implements ViewFinder
15
{
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @see ViewFinder::findTemplate()
20
     */
21 1
    public function findTemplate($view_model, $type)
22
    {
23 1
        $class = new ReflectionClass($view_model);
24
25 1
        $path = dirname($class->getFileName());
26
27 1
        $name = $class->getShortName();
28
29 1
        return $path . DIRECTORY_SEPARATOR . $name . ".{$type}.php";
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     *
35
     * @see ViewFinder::listSearchPaths()
36
     */
37 1
    public function listSearchPaths($view_model, $type)
38
    {
39 1
        return array_filter(array($this->findTemplate($view_model, $type)));
40
    }
41
}
42