Completed
Push — master ( 00d73b...7020aa )
by Tom
03:28
created

TwigElement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 4 1
getPath() 0 1 ?
A getEngine() 0 5 1
1
<?php
2
3
namespace Curlyspoon\Core\Elements;
4
5
use Twig_Loader_Filesystem;
6
use Twig_Environment;
7
8
abstract class TwigElement extends Element
9
{
10
    public function render(): string
11
    {
12
        return $this->getEngine()->render($this->name.'.twig', $this->getOptions());
13
    }
14
15
    abstract protected function getPath(): string;
16
17
    protected function getEngine(): Twig_Environment
18
    {
19
        $loader = new Twig_Loader_Filesystem($this->getPath());
20
        return new Twig_Environment($loader);
21
    }
22
}
23