Passed
Branch master (37a2f4)
by devosc
01:36
created

Find   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 26
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B find() 0 5 5
1
<?php
2
/**
3
 *
4
 */
5
6
namespace Mvc5\View\Template;
7
8
use Mvc5\Arg;
9
10
trait Find
11
{
12
    /**
13
     *
14
     */
15
    use Path;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $directory;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $extension = Arg::VIEW_EXTENSION;
26
27
    /**
28
     * @param string $name
29
     * @return string
30
     */
31 9
    protected function find(string $name) : string
32
    {
33 9
        return $this->path($name) ?? (
34 8
            (!$name || !$this->directory || false !== strpos($name, '.')) ? $name :
35 9
                $this->directory . (DIRECTORY_SEPARATOR === $name[0] ? $name : DIRECTORY_SEPARATOR . $name) . '.' . $this->extension
36
        );
37
    }
38
}
39