Completed
Push — master ( 089ad5...045fb9 )
by Richard
10:39
created

ConfigCollector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 32
ccs 0
cts 17
cp 0
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 8 4
A module() 0 4 1
A __construct() 0 5 1
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
    public function __construct(XoopsModule $module, &$configs)
40
    {
41
        $this->module = $module;
42
        $this->configs = &$configs;
43
    }
44
45
    public function add($pluginConfigs)
46
    {
47
        if (is_array($pluginConfigs) && !empty($pluginConfigs)) {
48
            foreach ($pluginConfigs as $config) {
49
                $this->configs[] = $config;
50
            }
51
        }
52
    }
53
54
    public function module()
55
    {
56
        return $this->module;
57
    }
58
}
59