FolderTemplate::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
namespace Yoanm\InitPhpRepository\Model;
3
4
/**
5
 * Class FolderTemplate
6
 */
7
class FolderTemplate extends Template
8
{
9
    /** @var Template[] */
10
    private $fileList = [];
11
12
    /**
13
     * @param string $id
14
     * @param string $path
15
     */
16
    public function __construct($id, $path)
17
    {
18
        parent::__construct($id, $path, $path);
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function getPath()
25
    {
26
        return $this->getId();
27
    }
28
29
    /**
30
     * @param Template $fileTemplate
31
     */
32
    public function addFile(Template $fileTemplate)
33
    {
34
        // Override namespace
35
        $fileTemplate->setNamespace($this->getNamespace());
36
        $this->fileList[$fileTemplate->getId()] = $fileTemplate;
37
    }
38
39
    /**
40
     * @return Template[]
41
     */
42
    public function getFileList()
43
    {
44
        return $this->fileList;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function setNamespace($namespace)
51
    {
52
        //override files namespace too
53
        foreach ($this->getFileList() as $fileTemplate) {
54
            $fileTemplate->setNamespace($namespace);
55
        }
56
57
        return parent::setNamespace($namespace);
58
    }
59
}
60