Completed
Branch master (55a138)
by Michael
03:21
created

FormFileCheckBox::render()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 4
Ratio 26.67 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 0
dl 4
loc 15
rs 9.2
c 0
b 0
f 0
1
<?php namespace XoopsModules\Extcal\Form;
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 FormFileCheckBox.
22
 */
23
class FormFileCheckBox extends \XoopsFormCheckBox
24
{
25
    /**
26
     * @param      $caption
27
     * @param      $name
28
     * @param null $value
29
     *
30
     * @return FormFileCheckBox
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
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
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...
46
            $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...
47
            $this->setName($newname);
48
        }
49
        foreach ($this->getOptions() as $value => $name) {
50
            $ret .= "<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...
51
            $ret .= ' checked';
52
            $ret .= $this->getExtra() . '>' . $name . "<br>\n";
53
        }
54
55
        return $ret;
56
    }
57
}
58