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 |
||
| 13 | class Form extends SimpleExtComponent { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | public function __construct(JsUtils $js=null) { |
||
| 23 | |||
| 24 | public function addField($identifier){ |
||
| 27 | |||
| 28 | public function setInline($value){ |
||
| 31 | |||
| 32 | public function setOn($value){ |
||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string $identifier |
||
| 40 | * @param Rule|string $type |
||
| 41 | * @param mixed $value |
||
| 42 | * @param string|NULL $prompt |
||
| 43 | */ |
||
| 44 | public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){ |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param FieldValidation $fieldValidation |
||
| 53 | */ |
||
| 54 | public function addFieldValidation($fieldValidation){ |
||
| 57 | |||
| 58 | public function setJs(JsUtils $js){ |
||
| 61 | |||
| 62 | View Code Duplication | public function getScript() { |
|
| 69 | } |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):