Completed
Push — 183-default-layout-ext ( a97107 )
by
unknown
10:37
created

ValidatePathRenderTemplate   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A renderTemplate() 0 8 4
1
<?php
2
3
namespace League\Plates\RenderTemplate;
4
5
use League\Plates;
6
7
final class ValidatePathRenderTemplate extends RenderTemplateDecorator
8
{
9
    private $file_exists;
10
11
    public function __construct(Plates\RenderTemplate $render, $file_exists = 'file_exists') {
12
        parent::__construct($render);
13
        $this->file_exists = $file_exists;
14
    }
15
16
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $rt = null) {
17
        $path = $template->get('path');
18
        if (!$path || ($this->file_exists)($path)) {
19
            return $this->render->renderTemplate($template, $rt ?: null);
20
        }
21
22
        throw new Plates\Exception\RenderTemplateException('Template path ' . $path . ' is not a valid path for template: ' . $template->name);
23
    }
24
}
25