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 |
||
| 8 | class DateTime extends Property |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * {@inheritdoc} |
||
| 12 | * @throws \RuntimeException |
||
| 13 | */ |
||
| 14 | 21 | public function validateConfig($name, &$value) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | * @throws \RuntimeException |
||
| 43 | */ |
||
| 44 | 21 | protected function normalize(&$value) |
|
| 79 | |||
| 80 | /** |
||
| 81 | * {@inheritdoc} |
||
| 82 | */ |
||
| 83 | 1 | protected function initConfig() |
|
| 90 | } |
||
| 91 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.