SmartFormSectionClose   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 40
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getValue() 4 4 1
A render() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace XoopsModules\Smartobject\Form\Elements;
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    XOOPS Project https://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team, Kazumi Ono (AKA onokazu)
18
 */
19
20
use XoopsModules\Smartobject;
21
22
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
23
24
/**
25
 * Class SmartFormSectionClose
26
 */
27 View Code Duplication
class SmartFormSectionClose extends \XoopsFormElement
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
28
{
29
    /**
30
     * Text
31
     * @var string
32
     * @access  private
33
     */
34
    public $_value;
35
36
    /**
37
     * SmartFormSectionClose constructor.
38
     * @param      $sectionname
39
     * @param bool $value
40
     */
41
    public function __construct($sectionname, $value = false)
42
    {
43
        $this->setName($sectionname);
44
        $this->_value = $value;
0 ignored issues
show
Documentation Bug introduced by
The property $_value was declared of type string, but $value is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
45
    }
46
47
    /**
48
     * Get the text
49
     *
50
     * @return string
51
     */
52
    public function getValue()
53
    {
54
        return $this->_value;
55
    }
56
57
    /**
58
     * Prepare HTML for output
59
     *
60
     * @return string
61
     */
62
    public function render()
63
    {
64
        return $this->getValue();
65
    }
66
}
67