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 |
||
| 5 | abstract class Validator implements ValidatorInterface{ |
||
| 6 | protected $modifiedMessage; |
||
| 7 | protected $message; |
||
| 8 | protected $member; |
||
| 9 | protected $value; |
||
| 10 | |||
| 11 | public function validate_($value,$member,$instance,$params,$severity='warning',$message=null){ |
||
| 20 | |||
| 21 | protected function setParams(array $params){ |
||
| 26 | /** |
||
| 27 | * @return mixed |
||
| 28 | */ |
||
| 29 | public function getMember() { |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param mixed $member |
||
| 35 | */ |
||
| 36 | public function setMember($member) { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritDoc} |
||
| 42 | * @see \Ubiquity\contents\validation\validators\ValidatorInterface::getParameters() |
||
| 43 | */ |
||
| 44 | public function getParameters(): array { |
||
| 48 | |||
| 49 | protected function mergeMessages(){ |
||
| 56 | |||
| 57 | protected function _getMessage(){ |
||
| 65 | |||
| 66 | } |
||
| 67 | |||
| 68 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.