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 |
||
16 | View Code Duplication | class LimitOperation implements IntermediateOperation |
|
17 | { |
||
18 | /** @var int */ |
||
19 | private $limit; |
||
20 | |||
21 | /** |
||
22 | * @param int $limit |
||
23 | */ |
||
24 | 2 | public function __construct($limit) |
|
28 | |||
29 | /** |
||
30 | * @param mixed $input The element in the stream |
||
31 | * @param mixed $index The index in the input iterator |
||
32 | * @param IntermediateContext $context The solving context |
||
33 | * |
||
34 | * @return mixed |
||
35 | */ |
||
36 | 2 | public function apply($input, $index, IntermediateContext $context) |
|
52 | } |
||
53 |