Completed
Pull Request — v3 (#281)
by
unknown
11:23
created

NameAndFolderResolveTemplatePath   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
3
namespace League\Plates\Template\ResolveTemplatePath;
4
5
use League\Plates\Exception\TemplateNotFound;
6
use League\Plates\Template\Name;
7
use League\Plates\Template\ResolveTemplatePath;
8
9
/** Resolves the path from the logic in the Name class which resolves via folder lookup, and then the default directory */
10
final class NameAndFolderResolveTemplatePath implements ResolveTemplatePath
11
{
12
    public function __invoke(Name $name): string {
13
        $path = $name->getPath();
14
        if (is_file($path)) {
15
            return $path;
16
        }
17
18
        throw new TemplateNotFound($name->getName(), [$name->getPath()], 'The template "' . $name->getName() . '" could not be found at "' . $name->getPath() . '".');
19
    }
20
}
21