Completed
Push — master ( 9200bf...e0f8ea )
by Richard
15s
created

ConfigCollector::add()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.2
c 1
b 1
f 0
cc 4
eloc 4
nc 3
nop 1
crap 4
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
namespace Xoops\Module\Plugin;
13
14
use Xoops\Core\Kernel\Handlers\XoopsModule;
15
16
/**
17
 * Facilitates adding configuration requirements for a plugin to the configuration array for
18
 * a consuming module.
19
 *
20
 * This is used for the argument for the event 'system.module.update.configs', and the listeners,
21
 * presumably plugin providers, can access module details and add to the configuration as needed.
22
 *
23
 * @copyright   2013-2015 XOOPS Project (http://xoops.org)
24
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
25
 * @author      Richard Griffith <[email protected]>
26
 */
27
class ConfigCollector
28
{
29
    public $module;
30
31
    public $configs;
32
33
    /**
34
     * __construct
35
     *
36
     * @param XoopsModule $module  consuming module being installed
37
     * @param array       $configs configuration array for the consuming module
38
     */
39 3
    public function __construct(XoopsModule $module, &$configs)
40
    {
41 3
        $this->module = $module;
42 3
        $this->configs = &$configs;
43 3
    }
44
45 1
    public function add($pluginConfigs)
46
    {
47 1
        if (is_array($pluginConfigs) && !empty($pluginConfigs)) {
48 1
            foreach ($pluginConfigs as $config) {
49 1
                $this->configs[] = $config;
50
            }
51
        }
52 1
    }
53
54 1
    public function module()
55
    {
56 1
        return $this->module;
57
    }
58
}
59