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

GroupCheckbox   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
ccs 10
cts 11
cp 0.9091
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
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\Form;
13
14
/**
15
 * GroupCheckbox - select group(s) using checkboxes
16
 *
17
 * @category  Xoops\Form\GroupCheckbox
18
 * @package   Xoops\Form
19
 * @author    John Neill <[email protected]>
20
 * @copyright 2001-2015 XOOPS Project (http://xoops.org)
21
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22
 * @link      http://xoops.org
23
 */
24
class GroupCheckbox extends Checkbox
25
{
26
    /**
27
     * Constructor
28
     *
29
     * @param string|array $caption Caption or array of all attributes
30
     * @param string       $name    element name
31
     * @param mixed        $value   Pre-selected value (or array of them).
32
     */
33 1
    public function __construct($caption, $name = null, $value = null)
34
    {
35 1
        if (is_array($caption)) {
36
            parent::__construct($caption);
37
        } else {
38 1
            parent::__construct([]);
39 1
            $this->setWithDefaults('caption', $caption, '');
40 1
            $this->setWithDefaults('name', $name, 'name_error');
41 1
            $this->set('value', $value);
42
        }
43 1
        $this->set(':inline');
44 1
        $userGroups = \Xoops::getInstance()->getHandlerMember()->getGroupList();
45 1
        $this->addOptionArray($userGroups);
46 1
    }
47
}
48