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 SizeRule extends StandardRule |
|
12 | { |
||
13 | private $maxSize; |
||
14 | |||
15 | protected $contentTypes = array('image'); |
||
16 | |||
17 | /** |
||
18 | * @param int $maxSize The maximum size of an image file in kilobytes |
||
19 | */ |
||
20 | public function init($maxSize = 100) |
||
24 | |||
25 | protected function doValidation(ResponseInterface $response) |
||
30 | } |
||
31 |