Completed
Pull Request — master (#2)
by Edgard
06:24
created

Directory::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development.
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\components;
12
13
use hidev\helpers\FileHelper;
14
use Yii;
15
16
/**
17
 * Directory manipulation component.
18
 */
19
class Directory extends File
20
{
21
    public function save()
22
    {
23
        FileHelper::mkdir($this->_path);
24
25
        foreach ($this->getItems() as $id => $config) {
26
            $type = isset($config['template']) || isset($config['copy']) ? 'File' : 'Directory';
27
            $defaults = [
28
                'class' => "hidev\\components\\$type",
29
                'path'  => $this->_path . '/' . $id,
30
            ];
31
            $config = array_merge($defaults, $config ?: []);
32
            $object = Yii::createObject($config);
33
            $object->save();
34
        }
35
36
        $this->modifyFile();
37
    }
38
39
    public function load()
40
    {
41
    }
42
}
43