PlatesHtmlTranslator::template()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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