Passed
Push — master ( 743cc2...6ffec3 )
by Oleg
02:50
created

AbstractAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 6 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Controllers;
5
6
use SlayerBirden\DFCodeGeneration\Generator\GeneratorInterface;
7
use Twig\Environment;
8
use Twig\Loader\FilesystemLoader;
9
10
abstract class AbstractAction implements GeneratorInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $template = '';
16
    /**
17
     * @var DataProviderInterface
18
     */
19
    protected $provider;
20
21 5
    public function __construct(DataProviderInterface $provider)
22
    {
23 5
        $this->provider = $provider;
24 5
    }
25
26
    /**
27
     * @return string
28
     * @throws \Twig_Error_Loader
29
     * @throws \Twig_Error_Runtime
30
     * @throws \Twig_Error_Syntax
31
     */
32 5
    public function generate(): string
33
    {
34 5
        $loader = new FilesystemLoader(__DIR__ . '/Templates');
35 5
        $twig = new Environment($loader);
36
37 5
        return $twig->load($this->template)->render($this->provider->provide());
38
    }
39
}
40