Directory   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 18
cp 0
rs 10
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 2 1
A save() 0 21 6
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-2018, 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 = 'Directory';
27
            if (isset($config['template']) || isset($config['copy'])) {
28
                $type = 'File';
29
            } elseif (isset($config['symlink'])) {
30
                $type = 'Symlink';
31
            }
32
            $defaults = [
33
                'class' => "hidev\\components\\$type",
34
                'path' => $this->_path . '/' . $id,
35
            ];
36
            $config = array_merge($defaults, $config ?: []);
37
            $object = Yii::createObject($config);
38
            $object->save();
39
        }
40
41
        $this->modifyFile();
42
    }
43
44
    public function load()
45
    {
46
    }
47
}
48