Completed
Push — v4.0-dev ( b01e70 )
by
unknown
01:53
created

Engine   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
dl 0
loc 26
rs 10
c 4
b 0
f 0
wmc 5
lcom 2
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A render() 0 6 1
A addContext() 0 3 1
A getContext() 0 3 1
1
<?php
2
3
namespace League\Plates;
4
5
/** API for the Plates system */
6
class Engine
7
{
8
    private $render;
9
    private $context;
10
11
    public function __construct(RenderTemplate $render = null) {
12
        $this->render = $render ?: new RenderTemplate\PlatesRenderTemplate();
13
        $this->context = [];
14
    }
15
16
    /** @return string */
17
    public function render($template_name, array $data) {
18
        $template = new Template($template_name, $data, [
19
            'engine' => $this,
20
        ]);
21
        return $this->render->renderTemplate($template);
22
    }
23
24
    public function addContext(array $context) {
25
        $this->context = array_merge($this->context, $context);
26
    }
27
28
    public function getContext() {
29
        return $this->context;
30
    }
31
}
32