Passed
Pull Request — master (#5)
by Carlos C
06:01 queued 02:12
created

PlatesHtmlTranslator::template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 2
cp 0
crap 2
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
    public function __construct(string $directory, string $template)
25
    {
26
        $this->directory = $directory;
27
        $this->template = $template;
28
    }
29
30
    public function translate(CfdiData $cfdiData): string
31
    {
32
        // __DIR__ is src/Builders
33
        $plates = new PlatesEngine($this->directory());
34
        return $plates->render($this->template(), ['cfdiData' => $cfdiData]);
35
    }
36
37
    public function directory(): string
38
    {
39
        return $this->directory;
40
    }
41
42
    public function template(): string
43
    {
44
        return $this->template;
45
    }
46
}
47