Completed
Push — master ( 375de1...c13e1e )
by Andrii
13:21
created

Vcsignore::load()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.2
cc 4
eloc 9
nc 6
nop 0
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
/**
14
 * VCS ignore component.
15
 */
16
class Vcsignore extends ConfigFile
17
{
18
    protected $_items = [
19
        'hidev-local.yml'           => 'hidev internals',
20
        '.hidev/composer.json'      => 'hidev internals',
21
        '.hidev/composer.lock'      => 'hidev internals',
22
        '.hidev/vendor'             => 'hidev internals',
23
        '.*.swp'                    => 'IDE & OS files',
24
        '.idea'                     => 'IDE & OS files',
25
        'nbproject'                 => 'IDE & OS files',
26
        '.buildpath'                => 'IDE & OS files',
27
        '.project'                  => 'IDE & OS files',
28
        '.settings'                 => 'IDE & OS files',
29
        'Thumbs.db'                 => 'IDE & OS files',
30
        '.DS_Store'                 => 'IDE & OS files',
31
    ];
32
33
    public function init()
34
    {
35
        $this->_path = $this->take('vcs')->ignorefile;
36
        $this->load();
37
    }
38
39
    /**
40
     * Load.
41
     */
42
    public function load()
43
    {
44
        $items = [];
45
        foreach ($this->take('binaries')->getItems() as $binary) {
46
            if ($vcsignore = $binary->getVcsignore()) {
47
                $items[$vcsignore] = 'Binaries';
48
            }
49
        }
50
        unset($items['git.phar']);
51
        $this->setItems($items);
52
        $items = $this->getFile()->load() ?: [];
53
        $this->setItems($items);
54
    }
55
56
    /**
57
     * Save.
58
     */
59
    public function save()
60
    {
61
        $this->getFile()->save();
62
    }
63
}
64