Passed
Push — master ( d2520f...3f8ec2 )
by Michael
02:50
created

FormRRuleCheckBox::render()   B

Complexity

Conditions 7
Paths 10

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 7.551
c 0
b 0
f 0
cc 7
eloc 14
nc 10
nop 0
1
<?php namespace XoopsModules\Extcal\Form;
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @package      extcal
17
 * @since
18
 * @author       XOOPS Development Team,
19
 */
20
21
/**
22
 * Class FormRRuleCheckBox.
23
 */
24
class FormRRuleCheckBox extends \XoopsFormCheckBox
0 ignored issues
show
Bug introduced by
The type XoopsFormCheckBox was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
{
26
    /**
27
     * @param      $caption
28
     * @param      $name
29
     * @param null $value
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $value is correct as it would always require null to be passed?
Loading history...
30
     */
31
    public function __construct($caption, $name, $value = null)
32
    {
33
        parent::__construct($caption, $name, $value);
34
    }
35
36
    /**
37
     * prepare HTML for output.
38
     *
39
     * @return string
40
     */
41
    public function render()
42
    {
43
        $ret = '<table><tr>';
44
        $i   = 0;
45
        if (count($this->getOptions()) > 1 && '[]' !== substr($this->getName(), -2, 2)) {
46
            $newname = $this->getName() . '[]';
47
            $this->setName($newname);
48
        }
49
        foreach ($this->getOptions() as $value => $name) {
50
            if (0 == (++$i) % 6) {
51
                $ret .= '</tr><tr>';
52
            }
53
            $ret .= "<td><input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'";
54
            if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) {
55
                $ret .= ' checked';
56
            }
57
            $ret .= $this->getExtra() . '>' . $name . "</td>\n";
58
        }
59
        $ret .= '</tr></table>';
60
61
        return $ret;
62
    }
63
}
64