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

class/form/formfilecheckbox.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 ExtcalFormFileCheckBox.
22
 */
23
class ExtcalFormFileCheckBox extends XoopsFormCheckBox
24
{
25
    /**
26
     * @param      $caption
27
     * @param      $name
28
     * @param null $value
29
     *
30
     * @return ExtcalFormFileCheckBox
31
     */
32
    public function __construct($caption, $name, $value = null)
33
    {
34
        parent::__construct($caption, $name, $value);
35
    }
36
37
    /**
38
     * prepare HTML for output.
39
     *
40
     * @return string
41
     */
42
    public function render()
43
    {
44
        $ret = '';
45 View Code Duplication
        if (count($this->getOptions()) > 1 && '[]' !== substr($this->getName(), -2, 2)) {
0 ignored issues
show
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
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...
46
            $newname = $this->getName() . '[]';
47
            $this->setName($newname);
48
        }
49
        foreach ($this->getOptions() as $value => $name) {
50
            $ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'";
51
            $ret .= ' checked';
52
            $ret .= $this->getExtra() . '>' . $name . "<br>\n";
53
        }
54
55
        return $ret;
56
    }
57
}
58