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 |
||
21 | class DocumentIterator extends AbstractResultsIterator |
||
22 | { |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $aggregations; |
||
|
|||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function __construct(array $rawData, Manager $manager, array $scroll = []) |
||
40 | |||
41 | /** |
||
42 | * Get a specific aggregation by name. It fetches from the top level only. |
||
43 | * |
||
44 | * @param string $name |
||
45 | * |
||
46 | * @return ValueAggregation|null |
||
47 | */ |
||
48 | View Code Duplication | public function getAggregation($name) |
|
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | protected function convertDocument(array $document) |
||
67 | } |
||
68 |