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

TemplateProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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