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 |
||
| 11 | View Code Duplication | class StringExistsRule extends StandardRule |
|
| 12 | { |
||
| 13 | private $string; |
||
| 14 | |||
| 15 | protected $contentTypes = array('text/html'); |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param int $string The string that the document must contain |
||
| 19 | */ |
||
| 20 | public function init($string) |
||
| 24 | |||
| 25 | protected function doValidation(ResponseInterface $response) |
||
| 30 | } |
||
| 31 |