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

TemplateProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 31
ccs 0
cts 13
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 8 2
A __construct() 0 5 1
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