Failed Conditions
Push — master ( 07197c...02c092 )
by Yo
02:21
created

FolderTemplate::setNamespace()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
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