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

NameAndFolderResolveTemplatePath::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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