Failed Conditions
Pull Request — master (#1)
by Yo
02:02
created

TemplateProcessor::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 6
1
<?php
2
namespace Yoanm\DefaultPhpRepository\Processor;
3
4
use Yoanm\DefaultPhpRepository\Exception\TargetFileExistsException;
5
use Yoanm\DefaultPhpRepository\Helper\TemplateHelper;
6
7
/**
8
 * Class TemplateProcessor
9
 */
10
class TemplateProcessor
11
{
12
    /** @var TemplateFileProcessor */
13
    private $templateFileProcessor;
14
    /** @var TemplateFolderProcessor */
15
    private $templateFolderProcessor;
16
17
    /**
18
     * @param TemplateHelper $templateHelper
19
     */
20
    public function __construct(TemplateHelper $templateHelper)
21
    {
22
        $this->templateFileProcessor = new TemplateFileProcessor($templateHelper);
23
        $this->templateFolderProcessor = new TemplateFolderProcessor($templateHelper);
24
    }
25
26
    /**
27
     * @param string $templatePath
28
     * @param string $outputDir
29
     *
30
     * @throws TargetFileExistsException
31
     */
32
    public function process($templatePath, $outputDir = '.')
33
    {
34
        if (is_dir($templatePath)) {
35
            $this->templateFolderProcessor->process($templatePath, $outputDir);
36
        } else {
37
            $this->templateFileProcessor->process($templatePath, $outputDir);
38
        }
39
    }
40
}
41