LayoutRenderTemplate   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 3

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

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 24
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $rt = null) {
10 24
        $ref = $template->reference;
11 24
        $content = $this->render->renderTemplate($template, $rt ?: $this);
12
13 24
        $layout_ref = $ref()->get('layout');
14 24
        if (!$layout_ref) {
15 24
            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 20
        return function(Plates\RenderTemplate $render) {
26 20
            return new static($render);
27 20
        };
28
    }
29
}
30
31
32