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  | 
            ||
| 19 | class RadioElement extends AbstractTabindexElement implements MultiOptionElementInterface  | 
            ||
| 20 | { | 
            ||
| 21 | /** @var string */  | 
            ||
| 22 | protected $type = 'radio';  | 
            ||
| 23 | /** @var array */  | 
            ||
| 24 | protected $options = [];  | 
            ||
| 25 | /** @var array */  | 
            ||
| 26 | protected $optionGroups = [];  | 
            ||
| 27 | |||
| 28 | /**  | 
            ||
| 29 | * Resets the object when cloning.  | 
            ||
| 30 | */  | 
            ||
| 31 | 1 | public function __clone()  | 
            |
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Sets element value.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @param mixed $value  | 
            ||
| 43 | * @return RadioElement  | 
            ||
| 44 | */  | 
            ||
| 45 | 2 | public function setValue($value)  | 
            |
| 60 | |||
| 61 | /**  | 
            ||
| 62 | * Collects the selected values for multi option element.  | 
            ||
| 63 | *  | 
            ||
| 64 | * @param $value  | 
            ||
| 65 | * @return array  | 
            ||
| 66 | */  | 
            ||
| 67 | 4 | protected function getValuesToSelect($value)  | 
            |
| 83 | |||
| 84 | /**  | 
            ||
| 85 | * Returns element value.  | 
            ||
| 86 | *  | 
            ||
| 87 | * @return mixed  | 
            ||
| 88 | */  | 
            ||
| 89 | 2 | View Code Duplication | public function getValue()  | 
            
| 101 | |||
| 102 | /**  | 
            ||
| 103 | * Set label-value options for the element.  | 
            ||
| 104 | *  | 
            ||
| 105 | * @param array $options  | 
            ||
| 106 | * @return RadioElement  | 
            ||
| 107 | */  | 
            ||
| 108 | 2 | public function setOptions(array $options)  | 
            |
| 128 | |||
| 129 | /**  | 
            ||
| 130 | * Sets label-value option for the element.  | 
            ||
| 131 | *  | 
            ||
| 132 | * @param string $label  | 
            ||
| 133 | * @param string $value  | 
            ||
| 134 | * @param boolean $checked  | 
            ||
| 135 | * @param string $group  | 
            ||
| 136 | * @param array $attributes  | 
            ||
| 137 | * @return RadioElement  | 
            ||
| 138 | */  | 
            ||
| 139 | 2 | protected function setOption($label, $value, $checked, $group, array $attributes = [])  | 
            |
| 151 | |||
| 152 | /**  | 
            ||
| 153 | * Checks if the element has value options.  | 
            ||
| 154 | *  | 
            ||
| 155 | * @return bool  | 
            ||
| 156 | */  | 
            ||
| 157 | 1 | public function hasOptions()  | 
            |
| 161 | |||
| 162 | /**  | 
            ||
| 163 | * Gets element value options.  | 
            ||
| 164 | *  | 
            ||
| 165 | * @return array  | 
            ||
| 166 | */  | 
            ||
| 167 | 1 | public function getOptions()  | 
            |
| 171 | }  | 
            ||
| 172 | 
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.