PlatesHtmlTranslator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A directory() 0 3 1
A translate() 0 5 1
A __construct() 0 4 1
A template() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\CfdiToPdf\Builders\HtmlTranslators;
6
7
use League\Plates\Engine as PlatesEngine;
8
use PhpCfdi\CfdiToPdf\CfdiData;
9
10
class PlatesHtmlTranslator implements HtmlTranslatorInterface
11
{
12
    /** @var string */
13
    private $directory;
14
15
    /** @var string */
16
    private $template;
17
18
    /**
19
     * PlatesHtmlTranslator constructor.
20
     *
21
     * @param string $directory
22
     * @param string $template
23
     */
24 1
    public function __construct(string $directory, string $template)
25
    {
26 1
        $this->directory = $directory;
27 1
        $this->template = $template;
28
    }
29
30 1
    public function translate(CfdiData $cfdiData): string
31
    {
32
        // __DIR__ is src/Builders
33 1
        $plates = new PlatesEngine($this->directory());
34 1
        return $plates->render($this->template(), ['cfdiData' => $cfdiData]);
35
    }
36
37 1
    public function directory(): string
38
    {
39 1
        return $this->directory;
40
    }
41
42 1
    public function template(): string
43
    {
44 1
        return $this->template;
45
    }
46
}
47