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

Directory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 24
ccs 0
cts 18
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B save() 0 17 5
A load() 0 3 1
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