LayoutRenderTemplate   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderTemplate() 0 14 4
A factory() 0 5 1
1
<?php
2
3
namespace League\Plates\Extension\LayoutSections;
4
5
use League\Plates;
6
7
final class LayoutRenderTemplate extends Plates\RenderTemplate\RenderTemplateDecorator
8
{
9 28
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $rt = null) {
10 28
        $ref = $template->reference;
11 28
        $content = $this->render->renderTemplate($template, $rt ?: $this);
12
13 28
        $layout_ref = $ref()->get('layout');
14 28
        if (!$layout_ref) {
15 28
            return $content;
16
        }
17
18 16
        $layout = $layout_ref()->with('sections', $ref()->get('sections'));
19 16
        $layout->get('sections')->add('content', $content);
20
21 16
        return ($rt ?: $this)->renderTemplate($layout);
22
    }
23
24
    public static function factory() {
25 24
        return function(Plates\RenderTemplate $render) {
26 24
            return new static($render);
27 24
        };
28
    }
29
}
30
31
32