Completed
Push — master ( cfbca0...20c8dd )
by Andrii
14:34
created

Vcsignore::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
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/composer.json'      => 'hidev internals',
20
        '.hidev/composer.lock'      => 'hidev internals',
21
        '.hidev/runtime'            => 'hidev internals',
22
        '.hidev/vendor'             => 'hidev internals',
23
        'hidev-local.yml'           => 'hidev internals',
24
        '.*.swp'                    => 'IDE & OS files',
25
        '.idea'                     => 'IDE & OS files',
26
        'nbproject'                 => 'IDE & OS files',
27
        '.buildpath'                => 'IDE & OS files',
28
        '.project'                  => 'IDE & OS files',
29
        '.settings'                 => 'IDE & OS files',
30
        'Thumbs.db'                 => 'IDE & OS files',
31
        '.DS_Store'                 => 'IDE & OS files',
32
    ];
33
34
    public function init()
35
    {
36
        $this->_path = $this->take('vcs')->ignorefile;
37
        $this->load();
38
    }
39
40
    /**
41
     * Load.
42
     */
43
    public function load()
44
    {
45
        $items = [];
46
        foreach ($this->take('binaries')->getItems() as $binary) {
47
            if ($vcsignore = $binary->getVcsignore()) {
48
                $items[$vcsignore] = 'Binaries';
49
            }
50
        }
51
        unset($items['git.phar']);
52
        $this->setItems($items);
53
        $items = $this->getFile()->load() ?: [];
54
        $this->setItems($items);
55
    }
56
}
57