Completed
Push — master ( 68c045...6d06de )
by Michael
02:34
created

ExtcalFormRRuleCheckBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      extcal
16
 * @since
17
 * @author       XOOPS Development Team,
18
 */
19
20
/**
21
 * Class ExtcalFormRRuleCheckBox.
22
 */
23
class ExtcalFormRRuleCheckBox extends XoopsFormCheckBox
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
24
{
25
    /**
26
     * @param      $caption
27
     * @param      $name
28
     * @param null $value
29
     */
30
    public function __construct($caption, $name, $value = null)
31
    {
32
        parent::__construct($caption, $name, $value);
33
    }
34
35
    /**
36
     * prepare HTML for output.
37
     *
38
     * @return string
39
     */
40
    public function render()
41
    {
42
        $ret = '<table><tr>';
43
        $i   = 0;
44 View Code Duplication
        if (count($this->getOptions()) > 1 && '[]' !== substr($this->getName(), -2, 2)) {
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
            $newname = $this->getName() . '[]';
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
46
            $this->setName($newname);
47
        }
48
        foreach ($this->getOptions() as $value => $name) {
49
            if (0 == (++$i) % 6) {
50
                $ret .= '</tr><tr>';
51
            }
52
            $ret .= "<td><input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'";
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
53
            if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) {
54
                $ret .= ' checked';
55
            }
56
            $ret .= $this->getExtra() . '>' . $name . "</td>\n";
57
        }
58
        $ret .= '</tr></table>';
59
60
        return $ret;
61
    }
62
}
63