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

MockRenderTemplate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A renderTemplate() 0 7 2
1
<?php
2
3
namespace League\Plates\RenderTemplate;
4
5
use League\Plates;
6
7
final class MockRenderTemplate implements Plates\RenderTemplate
8
{
9
    private $mocks;
10
11
    public function __construct(array $mocks) {
12
        $this->mocks = $mocks;
13
    }
14
15
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $rt = null) {
16
        if (!isset($this->mocks[$template->name])) {
17
            throw new Plates\Exception\RenderTemplateException('Mock include does not exist for name: ' . $template->name);
18
        }
19
20
        return $this->mocks[$template->name]($template);
21
    }
22
}
23